Topic
Option
Option is a built-in Rust enum that replaces null. Instead of letting a missing value crash your program, Option forces you to handle both possibilities: Some(value) when data exists, None when it doesn't. Every function that might not find what it's looking for returns Option, and match or if let makes it safe to unwrap.
Quick Reference
ConceptWhat it means
OptionA built-in enum that replaces "null" in Rust. It says "this might have a value, or it might not."
Some(T)One variant of Option that wraps an actual value. Some(5) means "there is a value, and it's 5."
NoneThe other variant of Option. None means "there is no value."
match on OptionThe standard way to handle both possibilities - check for Some and None.
if letA shorter way to unwrap Some when you only care about the value-carrying case.
PreludeRust's built-in types (like Option) that you can use without importing anything.
TermWhat it meansWhen you use it
OptionA built-in enum that replaces null in RustWhen a value might or might not exist
Some(T)The variant that wraps an actual valueWhen you have a value and want to signal it exists
NoneThe variant that means there is no valueWhen indicating the absence of a value
match on OptionThe standard way to handle both Some and None casesWhen you need to handle both the present and absent cases explicitly
if letA shorter way to unwrap Some when you only care about the value caseWhen you only need to act if a value is present
PreludeRust built-in types available without any import statementOption, String, Vec - always available, no use needed