unsafe doesn't turn off the borrow checker. It unlocks five extra abilities,
and makes me responsible for upholding the rules the compiler can no longer check.
What unsafe allows
- Dereference a raw pointer (
*const T,*mut T) - Call an
unsafefunction (including FFI) - Read or write a mutable
static - Implement an
unsafetrait (Send,Sync, …) - Access fields of a
union
To learn
- Writing
// SAFETY:comments that state the invariant being upheld - Building safe APIs on top of unsafe code
- Raw pointers vs references: aliasing and validity rules
MaybeUninit,transmute, and why they're easy to misuse