<分区>
在下面的代码中,我希望编译器在 hello
函数自 mutable references do not implement Copy
以来的第二次调用时提示 use of moved value: xref。编译器不会引发任何此类错误。我在这里缺少什么?
fn main() {
let mut x: String = "Developer".to_string();
let x_ref: &mut String = &mut x;
hello(x_ref);
hello(x_ref);
}
fn hello(a: &mut String) {
println!("Hello {}", a);
}