The most common reason to use unsafe is FFI — the Foreign Function Interface, how Rust talks to C libraries and operating-system APIs. It's also how Rust slots into existing codebases written in other languages.
Calling C from Rust
An extern "C" block declares functions from a C library; calling them is unsafe because the compiler can't verify the foreign code upholds Rust's guarantees. You declare the signature, link the library, and wrap the call — typically in a safe Rust function that validates inputs and outputs so callers never touch the raw FFI.
Why FFI matters
Decades of battle-tested C and system libraries exist; FFI lets Rust use them without rewriting. It also works the other way — Rust can expose a C-compatible API that C, Python, or any FFI-capable language calls. This two-way bridge is why Rust adopts incrementally: a single hot module rewritten in Rust can slot into a large C or Python codebase.
unsafe extern layer at the bottom and a safe, idiomatic Rust API on top. You audit the unsafe boundary once; everyone using the crate stays in safe Rust. Crates like the objc2 family do exactly this for macOS system APIs.The macOS example
A concrete case: on macOS, bringing a window to the front sometimes requires calling Cocoa's NSApplication.activate() — a system API with no pure-Rust equivalent. Crates in the objc2 family wrap that Objective-C FFI in a safe Rust interface. Cinder's native core uses exactly this pattern: a small, audited FFI layer to reach a macOS-only capability, exposed to the rest of the app as ordinary safe Rust. That's FFI doing its real job — reaching the platform without surrendering safety everywhere else.