Unsafe Rust
Unsafe Rust
What unsafe unlocks, what it promises, and how it goes wrong
What unsafe means
An unsafe block doesn't turn the borrow checker off. Everything inside it is still checked the normal way; it only unlocks five extra abilities the compiler can't verify on its own
- Dereference a raw pointer,
*const Tor*mut T - Call an
unsafefunction or method, including functions from C - Read or write a
static mut - Implement an
unsafetrait such asSendorSync - Read the fields of a
union