skip to content

Ownership is a type system, not a discipline

category: Rustdate: 1 min read
#rust#ownership#lifetimes#type-system

People describe Rust's borrow checker as a strict teacher. That framing makes you defensive. Ownership is better read as a type system over lifetimes — and once you do, the compiler's complaints start to read like type mismatches, not scolding.

RUST
// two views, one owner — the type says it all
fn split<'a>(buf: &'a mut [u8]) -> (&'a mut [u8], &'a mut [u8]) {
let mid = buf.len() / 2;
buf.split_at_mut(mid)
}

A lifetime is a type parameter. The borrow checker is unification. There is no discipline to maintain — only types to satisfy.

  • When the checker complains, ask: which lifetime won't unify, and why?
  • Most "fights" are actually early-returns holding a borrow longer than the type allows.
  • Arc<Mutex<T>> is a confession that the type-level story ran out. Use it last.