Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第13章 unsafe 块中 可变借用检查代码过期 #296

Open
ZhangHanDong opened this issue Jul 10, 2020 · 0 comments
Open

第13章 unsafe 块中 可变借用检查代码过期 #296

ZhangHanDong opened this issue Jul 10, 2020 · 0 comments
Labels
代码过期 代码因为Rust版本更新而过期 第十三章 第十三章

Comments

@ZhangHanDong
Copy link
Owner

现在的代码示例:

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规则,借用检查照样报错。

@ZhangHanDong ZhangHanDong added 第十三章 第十三章 代码过期 代码因为Rust版本更新而过期 labels Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
代码过期 代码因为Rust版本更新而过期 第十三章 第十三章
Projects
None yet
Development

No branches or pull requests

1 participant