Skip to main content

OptionExt

Trait OptionExt 

pub trait OptionExt<T> {
    // Required method
    fn try_map<O, E>(
        self,
        f: impl FnOnce(T) -> E,
    ) -> <<E as Try>::Residual as Residual<Option<O>>>::TryType
       where E: Try<Output = O>,
             <E as Try>::Residual: Residual<Option<O>>;
}
Expand description

Extension trait to implement try_map on Options.

Required Methods§

fn try_map<O, E>( self, f: impl FnOnce(T) -> E, ) -> <<E as Try>::Residual as Residual<Option<O>>>::TryType
where E: Try<Output = O>, <E as Try>::Residual: Residual<Option<O>>,

applies the fallible function f to the inner value of self and transposes the result. Given f: T -> Result<O, Err> we have try_map(f): Option<T> -> Result<Option<O>, Err>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl<T> OptionExt<T> for Option<T>

§

fn try_map<O, E>( self, f: impl FnOnce(T) -> E, ) -> <<E as Try>::Residual as Residual<Option<O>>>::TryType
where E: Try<Output = O>, <E as Try>::Residual: Residual<Option<O>>,

Implementors§