transpose method

Option<Result<S, F>> transpose()

Transposes a Result of an Option into an Option of a Result.

Implementation

Option<Result<S, F>> transpose() {
  if (isOk()) {
    final val = unwrap();
    if (val.v != null) {
      // ignore: null_check_on_nullable_type_parameter
      return Some(Ok(val.v!));
    }
    return None;
  } else {
    return Some(Err(unwrapErr()));
  }
}