This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <profiles version="21"> | |
| <profile kind="CodeFormatterProfile" name="Default" version="21"> | |
| <setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/> | |
| <setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="1"/> | |
| <setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> | |
| <setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/> | |
| <setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="true"/> | |
| <setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="0"/> | |
| <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="0"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [alias] | |
| pr = pull --rebase | |
| ls = log --graph --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cgreen\\ [%cn]" --decorate --abbrev-commit | |
| ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cgreen\\ [%cn]" --decorate --numstat | |
| lnc = log --pretty=format:"%h\\ %s\\ [%cn]" | |
| lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cgreen\\ [%cn]" --decorate --date=short | |
| clean-branches = !git branch | grep -v \" master$\" | xargs git branch -D | |
| checkpoint = commit -am 'checkpoint' | |
| last-message = log -n 1 --pretty=format:'%n%n%b' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let _ = media.write(text_bytes); | |
| // ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let mut array_wrapper = ArrayWrapper { | |
| buffer: vec![] | |
| }; | |
| let media: &mut dyn Write = &mut array_wrapper; | |
| write(media, "alô mundo!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Compiling playground v0.0.1 (/playground) | |
| Finished dev [unoptimized + debuginfo] target(s) in 1.21s | |
| Running `target/debug/playground` | |
| ArrayWrapper { buffer: [97, 108, 195, 180, 32, 109, 117, 110, 100, 111, 33] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn write(media: &mut dyn Write, text: &str) { | |
| // ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Compiling playground v0.0.1 (/playground) | |
| error[E0782]: trait objects must include the `dyn` keyword | |
| --> src/main.rs:22:22 | |
| | | |
| 22 | fn write(media: &mut Write, text: &str) { | |
| | ^^^^^ | |
| | | |
| help: add `dyn` keyword before this trait | |
| | | |
| 22 | fn write(media: &mut dyn Write, text: &str) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::Write; | |
| use std::io::Result; | |
| #[derive(Debug)] | |
| struct ArrayWrapper { | |
| pub buffer: Vec<u8>, | |
| } | |
| impl Write for ArrayWrapper { | |
| fn write(&mut self, buf: &[u8]) -> Result<usize> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::Write; | |
| use std::io::Result; | |
| #[derive(Debug)] | |
| struct ArrayWrapper { | |
| pub buffer: Vec<u8>, | |
| } | |
| impl Write for ArrayWrapper { | |
| fn write(&mut self, buf: &[u8]) -> Result<usize> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub trait Write { | |
| // escreve um buffer nesse escritor retornando | |
| // quantos bytes foram escritos em caso de sucesso | |
| fn write(&mut self, buf: &[u8]) -> Result<usize>; | |
| // limpa o escritor, garantindo que qualquer conteúdo | |
| // armazenado em buffers intermediários seja persistido | |
| // no armazenamento final | |
| fn flush(&mut self) -> Result<()>; |
NewerOlder