core.opt
Optional values: a payload or an explicit absence.
All modules · Writing docstrings
enum Opt[T]A value that may be absent. Match Val(value) or Non() to handle both cases.
let missing = Opt[Int].Nonprint(missing.unwrap_or(7))7Opt.Val
Section titled “Opt.Val”Val(T)A present value of type T.
Opt.Non
Section titled “Opt.Non”NonNo value.
Opt[@T]
Section titled “Opt[@T]”impl Opt[@T]Opt[@T].unwrap
Section titled “Opt[@T].unwrap”func unwrap(self): TReturn the payload. Stop with an error if this is Non.
Opt[@T].unwrap_or
Section titled “Opt[@T].unwrap_or”func unwrap_or(self, default: T): TReturn the payload, or default when absent. Arguments are evaluated before the call.