Skip to content

Instantly share code, notes, and snippets.

@kawakami-o3
Created February 18, 2019 14:29
Show Gist options
  • Save kawakami-o3/78804bc8cc55207127df42be5c2681da to your computer and use it in GitHub Desktop.
Save kawakami-o3/78804bc8cc55207127df42be5c2681da to your computer and use it in GitHub Desktop.
vector example in Rust
#[derive(Debug)]
struct Hoge {
a: i32,
b: i32,
}
fn main() {
let mut v = Vec::new();
v.push(Hoge{a: 1, b: 2});
v.push(Hoge{a: 2, b: 4});
v.push(Hoge{a: 3, b: 6});
println!("{:?}", v);
let h = &mut v[1];
h.a = 10;
println!("{:?}", h);
println!("{:?}", v);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment