2 ms·
This is not a new thing, whenever you use the "unsafe" keyword you have to pay attention to undefined behavior. For instance, having two "mut" references at the
by cesarb 6y ago
This is not a new thing, whenever you use the "unsafe" keyword you have to pay attention to undefined behavior. For instance, having two "mut" references at the same time to the same memory has always been undefined behavior in Rust; you cannot construct them without "unsafe", but it's very easy to do with "unsafe" (just cast to a pointer and back). In the same way, "unsafe" allows you to construct references with an arbitrary lifetime, and many other potentially-undefined things; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html https://doc.rust-lang.org/reference/behavior-considered-unde... for a list.
I don't think Rust will "get to where C++ is" (whatever that means), because (outside of compiler bugs) you will not have undefined behavior unless you use "unsafe", and most Rust code doesn't use "unsafe"; the pieces that do use "unsafe" can be carefully audited (instead of auditing the whole code).