Conceptual
Login

The Option Type

Option<T> encodes presence (Some(T)) or absence (None) in the type system, replacing null pointers; the compiler forces every consumer to handle both arms before touching the value. Niche optimization makes Option<&T> the same size as a raw pointer.

Questions this Concept answers

  • Why does modelling absence with `Option` remove the family of bugs caused by null pointers?