第13章 unsafe 块中 可变借用检查代码过期
Opened this issue · 0 comments
ZhangHanDong commented
现在的代码示例:
fn main(){
unsafe {
let mut a = "hello";
let b = &a;
let c = &mut a;
}
}
按书中的描述,本来应该报借用检查的错误,但是现在因为NLL的引入,上面代码已经正常编译了。
所以,需要修正。要么更改文本说明,要么修改代码为:
fn main(){
unsafe {
let mut a = "hello";
let b = &a;
let c = &mut a;
b;
}
}
上面代码违反了NLL规则,借用检查照样报错。