unwrapOrElse method

T unwrapOrElse(
  1. T elseFn()
)

Returns the held value of this Option if it is Some, or returns the returned value from elseFn if this Option is None.

See also: Rust: Option::unwrap_or_else()

Implementation

T unwrapOrElse(T Function() elseFn) {
  return switch (this) {
    Some(:T v) => v,
    None() => elseFn(),
  };
}