Created
February 18, 2019 14:29
-
-
Save kawakami-o3/78804bc8cc55207127df42be5c2681da to your computer and use it in GitHub Desktop.
vector example in Rust
This file contains 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
#[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