这个(非常愚蠢的)函数无法编译:
fn silliness(mut z: &mut int) {
z = &mut *z;
}
编译器输出:
$ rustc blah.rs
blah.rs:2:5: 2:16 error: cannot assign to `z` because it is borrowed
blah.rs:2 z = &mut *z;
^~~~~~~~~~~
blah.rs:2:14: 2:16 note: borrow of `z` occurs here
blah.rs:2 z = &mut *z;
^~
error: aborting due to previous error
在我看来,因为在任何时候只有一个参考z指向的内容,所以事情应该没问题。我不明白的是什么?