Skip to content

Instantly share code, notes, and snippets.

@dwrensha
Created August 1, 2014 21:03
Show Gist options
  • Save dwrensha/4d9fa08c1176ddf64352 to your computer and use it in GitHub Desktop.
Save dwrensha/4d9fa08c1176ddf64352 to your computer and use it in GitHub Desktop.
struct Foo {
x : Vec<int>, y : Vec<int>
}
fn main () {
let foo = box Foo { x : vec![1,2,3], y : vec![4,5,6]};
let box Foo { x, y } = foo;
}
@dwrensha
Copy link
Author

dwrensha commented Aug 1, 2014

test.rs:8:22: 8:23 error: use of partially moved value: foo.y
test.rs:8 let box Foo { x, y } = foo;
^
test.rs:8:19: 8:20 note: foo.x moved here because it has type collections::vec::Vec<int>, which is moved by default (use ref to override)
test.rs:8 let box Foo { x, y } = foo;

@dwrensha
Copy link
Author

dwrensha commented Aug 1, 2014

What do I do if I want to move foo.x one place and foo.y somewhere else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment