Skip to content
masterclass Buddy

Rust · Class

Option

Option<T> represents a value that may be present or absent. It is either Some(value) or None, and Rust code must handle both cases.

Last updated

Since
1.0.0

Syntax

pub enum Option<T> { None, Some(T), }

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • Some
  • None
  • Option::map
  • Option::and_then
  • Option::as_ref
  • Option::unwrap_or
  • Option::ok_or
  • Option::iter

Source: Option in std::option - Rust. Checked 2026-11-03.