Closed
Description
This program compiles:
struct NonCopy;
fn main() {
let x = Box::new((NonCopy, NonCopy));
let pair = *x;
let (_a, _b) = pair;
}
But this one does not:
struct NonCopy;
fn main() {
let x = Box::new((NonCopy, NonCopy));
let (_a, _b) = *x;
}
It fails with:
destr.rs:6:14: 6:16 error: use of moved value: `x`
destr.rs:6 let (_a, _b) = *x;
^~
destr.rs:6:10: 6:12 note: `x` moved here (through moving `x.0`) because it has type `NonCopy`, which is moved by default
destr.rs:6 let (_a, _b) = *x;
^~
destr.rs:6:10: 6:12 help: use `ref` to override
destr.rs:6 let (_a, _b) = *x;
^~
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
No labels