andThen<U> method

Option<U> andThen<U>(
  1. Option<U> fn(
    1. T
    )
)

Returns None<U> if this Option is None<T>, otherwise calls fn with the held value and returns the returned Option.

See also: Rust: Option::and_then()

Implementation

Option<U> andThen<U>(Option<U> Function(T) fn) {
  return switch (this) {
    Some(:T v) => fn(v),
    None() => None(),
  };
}