transpose method

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

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

Returns:

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

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

See also: Rust: Result::transpose()

Implementation

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