0
次のコードでは、の所有権がy
でlet y = x;
に移動されましたが、なぜx.s = 6
はまだ機能しますか?なぜ所有権が移っても、変数を別の値にバインドできますか?
struct MyStruct {
s: u32,
}
fn main() {
let mut x = MyStruct { s: 5u32 };
let y = x;
x.s = 6; //why this line does not cause an error?
println!("{}", y.s);
}