Closed
Description
fn test() {
let mut x = 42_i32;
let opt = Some(&mut x);
loop {
if let Some(_x) = opt {}
}
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0382]: use of moved value
--> src/lib.rs:5:21
|
5 | if let Some(_x) = opt {}
| ^^ value moved here, in previous iteration of loop
|
= note: move occurs because value has type `&mut i32`, which does not implement the `Copy` trait
help: borrow this field in the pattern to avoid moving `opt.0`
|
5 | if let Some(ref _x) = opt {}
| ^^^
help: consider creating a fresh reborrow of `opt.0` here
|
5 | if let Some(&mut *_x) = opt {}
| ^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.
error: could not compile `playground`
To learn more, run the command again with --verbose.
if let Some(&mut *_x) = opt {}
is not valid syntax.