You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structNonCopy;fnmain(){let x = Box::new((NonCopy,NonCopy));let pair = *x;let(_a, _b) = pair;}
But this one does not:
structNonCopy;fnmain(){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
The text was updated successfully, but these errors were encountered:
@florence I believe that one is because it does it in field order. "" is a &'static strwhich isCopy, so theabinding in the first one doesn't move out ofx, and hence doesn't invalidxfor theb` binding.
This program compiles:
But this one does not:
It fails with:
The text was updated successfully, but these errors were encountered: