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