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

Misinformation wrt the borrowing rules #4019

Open
gyorgybalazsi opened this issue Aug 20, 2024 · 0 comments
Open

Misinformation wrt the borrowing rules #4019

gyorgybalazsi opened this issue Aug 20, 2024 · 0 comments

Comments

@gyorgybalazsi
Copy link

Please stop spreading misinformation. This is perfectly good code using the latest version of Rust:

fn main() {
    let mut x = 5;
    let y = &mut x;

    *y += 1;

    println!("{}", x);
}

The compiler doesn't give the following error message you claim it does:

error: cannot borrow `x` as immutable because it is also borrowed as mutable
    println!("{}", x);
                   ^

Probably in a previous version of Rust this error was returned, but the version is not specified in the text, and if this part is outdated, probably there are many more irrelevant parts in the book.

Source: https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/references-and-borrowing.html

@gyorgybalazsi gyorgybalazsi changed the title Misinformation contained in the book Misinformation wrt the borrowing rules Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant