transpose method

Result<Option<T>, E> transpose()

Transposes this Option<Result<T, E>> into a Result<Option<T>, E>.

Returns:

Option<Result<int, String>> a = Some(Ok(1));
Result<Option<int>, String> b = Ok(Some(1));

print(a.transpose() == b); // prints: true

See also: Rust: Option::transpose()

Implementation

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