Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- struct Foo {
- a: u32,
- b: Vec<u32>,
- c: bool,
- d: Vec<u8>,
- }
- fn clone_foo(f: &Foo) -> Foo {
- Foo { b: f.b.clone(), d: f.d.clone(), ..*f }
- }
- fn main() {
- let foo = Foo { a: 1, b: Vec::new(), c: true, d: Vec::new(), };
- let bar = clone_foo(&foo);
- println!("foo={:?}, bar={:?}", foo, bar);
- }
Add Comment
Please, Sign In to add comment