Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The point is that it keeps track of multiple references and disallows mutable and immutable references at the same time across threads, for example, and disallows multiple mutable references altogether.

The rust borrow checker works on values, and all that, not just on objects with RAII.



Mutable references can never coexist with other references in Rust, regardless of whether they're on different threads.

This will not compile:

    let x = 42;
    let r1 = &x;
    let m1 = &mut x;
    println!("{r1}");




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: