Skip to content

Option

fn map[A, B](opt: Option[A], f: fn(A) -> B fails E(f) uses { R(f) }) -> Option[B] fails E(f) uses { R(f) }

Applies f to the contents of a Some. None stays None.

fn and_then[A, B](opt: Option[A], f: fn(A) -> Option[B] fails E(f) uses { R(f) }) -> Option[B] fails E(f) uses { R(f) }

Applies f, which returns an Option, to the contents of a Some and flattens the result. None stays None.

fn or[A](opt: Option[A], default: A) -> A

The value, or default if None.

fn is_some[A](opt: Option[A]) -> Bool

Whether it is Some.

fn is_none[A](opt: Option[A]) -> Bool

Whether it is None.

fn or_fail[A, E](opt: Option[A], err: E) -> A fails E

Fails with err if None ([error.fail]). Turns an Option into a failure, as in users.find(id).or_fail(NotFound(id:)).