pub const fn unwrap_err<T, E>(res: Result<T, E>) -> EExpand description
Const version of Result::unwrap_err without the Debug formatting.
Can also be used in combination with Result::is_err to match the result.
ยงExample
use const_util::result::unwrap_err;
const fn double<T>(res: Result<T, i32>) -> Result<T, i32> {
if res.is_err() {
Err(2 * unwrap_err(res))
} else {
res
}
}
assert_eq!(double(Err::<String, _>(1)), Err(2));