Re:The struggle with Rust
by zzzcpan on Tuesday January 24, 2017 @10:12AM
(#13471891)
As I understand it, you can't disable just borrow checker somewhere where you don't need it.
[ Parent
| on HN ]
Re:The struggle with Rust
by steveklabnik on Tuesday January 24, 2017 @12:03PM
(#13473139)
It's subtle. Unsafe Rust is a superset of safe Rust; that is, all valid safe Rust code is valid unsafe Rust code.
fn foo() {
unsafe {
let x = &5; // this is still going to get borrow checked
}
}
Since it's a superset, it gives you access to new tools, that don't interact with the borrow checker, rather than "turning the borrow checker off". fn foo() {
unsafe {
let x = *const 5; // this is not going to get borrow checked
}
}(*const is not valid syntax: the way to not-borrow something is to coerce/cast it to an unsafe pointer within the statement, so that the borrow ends at the ;, e.g. give x an explicit raw pointer type in the first example.)
Re:The struggle with Rust
by steveklabnik on Tuesday January 24, 2017 @03:09PM
(#13474994)
gah, i always mess this up, haha