Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. pub struct Person {
  2. pub name: String,
  3. }
  4.  
  5. fn main() {
  6. let mut ppl: Vec<Person> = vec![];
  7. ppl.push(Person{name: "Joe".to_owned()});
  8. ppl.push(Person{name: "Mike".to_owned()});
  9.  
  10. (&mut ppl[0]).name = "AA".to_owned();
  11. (&mut ppl[1]).name = "BB".to_owned();
  12.  
  13. for pp in &ppl {
  14. println!("{}", pp.name);
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement