okOrElse<E> method

Result<T, E> okOrElse<E>(
  1. E elseFn()
)

Converts this Option<T> into a Result<T, E> using the returned value from elseFn if None.

elseFn will only be evaluated if this Option is None.

Returns:

See also: Rust: Option::ok_or_else()

Implementation

Result<T, E> okOrElse<E>(E Function() elseFn) => switch (this) {
	Some(value: T value) => Ok(value),
	None() => Err(elseFn())
};