我正在寻找有关引用和可变引用类型的复制/移动语义的文档。
以下代码片段显示不可变引用 ( & T) 实现了Copytrait 而可变引用 ( &mut T) 没有。
struct T;
fn copyable<U>(_: U) where U: Copy {}
fn main() {
let a = &T;
copyable(a); // OK
let b = &mut T;
copyable(b);
// error: the trait `core::marker::Copy` is not implemented for the type `&mut T`
}
Run Code Online (Sandbox Code Playgroud)
但我找不到这种行为的描述。有人知道一些(非)官方文件吗?(还是我错了?)
rust ×2