Trait TryUnwrapResult

Source
pub trait TryUnwrapResult {
    type T;
    type E;

    // Required method
    fn try_unwrap(self) -> Result<Self::T, Self::E>;
}
Expand description

Trait for implementing try_unwrap() on the generic Result<T, E> type.

Required Associated Types§

Source

type T

Source

type E

Required Methods§

Source

fn try_unwrap(self) -> Result<Self::T, Self::E>

Implementations on Foreign Types§

Source§

impl<T, E> TryUnwrapResult for Result<T, E>

Source§

fn try_unwrap(self) -> Result<T, E>

Unwraps and returns the contained value if it is an Ok. Otherwise, it returns an Err.

let ok: Result<i32, ()> = Ok(3);
assert_eq!(ok.try_unwrap(), Ok(3));
let err: Result<(), i32> = Err(2);
assert_eq!(err.try_unwrap(), Err(2));
Source§

type T = T

Source§

type E = E

Implementors§