transposeOpt method
Transposes a Result
of an Option
into an Option
of a Result
.
Ok(None)
will be mapped to None
.
Ok(Some(_))
and Err(_)
will be mapped to Some(Ok(_))
and
Some(Err(_))
.
Implementation
Option<Result<T, E>> transposeOpt() {
if (isOk) {
return unwrap().map((value) => Ok(value));
} else {
return Some(Err(unwrapErr()));
}
}