pub trait TryUnwrapOption {
    type T;

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

Trait for implementing try_unwrap() on the generic Option<T> type.

Required Associated Types§

source

type T

Required Methods§

source

fn try_unwrap(self) -> Option<Self::T>

Implementations on Foreign Types§

source§

impl<T> TryUnwrapOption for Option<T>

source§

fn try_unwrap(self) -> Option<T>

Unwraps and returns the contained value if it is a Some. Otherwise, it returns a None.

let some: Option<i32> = Some(4);
assert_eq!(some.try_unwrap(), Some(4));
let none: Option<i32> = None;
assert_eq!(none.try_unwrap(), None);
§

type T = T

Implementors§