Function transpose_option
Source pub fn transpose_option<T>(opt: Option<Result<T>>) -> Result<Option<T>>
Expand description
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(_).
§Examples
ⓘlet x: Option<Result<i32>> = Some(Ok(5));
let y: Result<Option<i32>> = transpose_option(x);
assert_eq!(y, Ok(Some(5)));