Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. struct Foo {
  2. s: String
  3. }
  4.  
  5. fn main() {
  6. let dest: &mut Vec<&str> = &mut Vec::new();
  7. let source: Vec<Foo> = vec![
  8. Foo { s: String::from("example") },
  9. Foo { s: String::from("with") },
  10. Foo { s: String::from("vector") }
  11. ];
  12.  
  13. for a in source {
  14. match a {
  15. Foo {s} => dest.push(s.as_str())
  16. }
  17. }
  18.  
  19. println!("{:?}", dest);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement