struct S {
a: String,
}
fn main() {
let mut s1 = S {
a: String::from("aaa"),
};
let mut s2 = S {
a: String::from("bbb"),
};
let a = (&mut s1, &mut s2);
let b = a.1; // the second element of a has been moved, thus only the first element left
let d = a.0; // this is ok;
let c = a; //compile failed
}
error[E0382]: use of moved value: `a`
--> src/main.rs:15:13
|
14 | let b = a.1;
| --- value moved here
15 | let c = a;
| ^ value used here after partial move
|
= note: move occurs because `a.1` has type `&mut S`, which does not implement the `Copy` trait