Guest User

Untitled

a guest
Jul 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #[derive(Debug)]
  2. struct Foo {
  3. a: u32,
  4. b: Vec<u32>,
  5. c: bool,
  6. d: Vec<u8>,
  7. }
  8.  
  9. fn clone_foo(f: &Foo) -> Foo {
  10. Foo { b: f.b.clone(), d: f.d.clone(), ..*f }
  11. }
  12.  
  13. fn main() {
  14. let foo = Foo { a: 1, b: Vec::new(), c: true, d: Vec::new(), };
  15. let bar = clone_foo(&foo);
  16.  
  17. println!("foo={:?}, bar={:?}", foo, bar);
  18. }
Add Comment
Please, Sign In to add comment