Everything in this quest has been safe Rust — the borrow checker proving your code sound. unsafe is the escape hatch: a small, explicit doorway where you take responsibility for guarantees the compiler can't verify.
What unsafe actually unlocks
A common myth: unsafe turns off the borrow checker. It doesn't. It enables exactly five extra abilities — dereference a raw pointer, call an unsafe function, access or modify a mutable static, implement an unsafe trait, and access union fields. Everything else — ownership, borrowing, lifetimes — still applies inside an unsafe block. It's a narrow exception, not a free-for-all.
You take on the proof
Inside unsafe, you guarantee what the compiler normally proves: that a raw pointer is valid, that no data race occurs, that invariants hold. The compiler trusts you. That's why unsafe blocks are kept small and scrutinized — every one is a place where a bug becomes possible again, so you keep them tiny and obvious.
unsafe core behind a safe public API, so callers never touch unsafe themselves. Vec, Rc, and much of std are exactly this: carefully-audited unsafe internals exposing a 100% safe interface. You localize the risk, prove it once, and everyone above is safe.When you actually need it
Most Rust programmers write little or no unsafe. You reach for it to call C libraries (FFI, next lesson), to build a data structure the borrow checker can't express, or for a specific hardware or performance need. The rule: stay in safe Rust until you have a concrete reason not to, and when you must go unsafe, wrap it so the rest of your program stays safe.