Skip to content

Instantly share code, notes, and snippets.

View roneygomes's full-sized avatar
✌️

Roney Gomes roneygomes

✌️
View GitHub Profile
@roneygomes
roneygomes / java_formatting_settings.xml
Last active December 27, 2023 21:22
Java Format Eclipse Settings
<?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"/>
@roneygomes
roneygomes / git aliases
Created November 30, 2021 22:49
my git aliases
[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'
let _ = media.write(text_bytes);
// ...
let mut array_wrapper = ArrayWrapper {
buffer: vec![]
};
let media: &mut dyn Write = &mut array_wrapper;
write(media, "alô mundo!");
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] }
fn write(media: &mut dyn Write, text: &str) {
// ...
}
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) {
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> {
@roneygomes
roneygomes / rust-polimorfismo-1.rs
Last active November 27, 2021 02:34
a escrita como operação polimórfica
// escrevendo em papel
fn write_on_paper(media: &mut Paper, text: &str);
// escrevendo num computador
fn write_on_computer(media: &mut Computer, text: &str);
// escrevendo na areia
fn write_on_sand(media: &mut Sand, text: &str);
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> {