WithContext

Trait WithContext 

Source
pub trait WithContext: Sized {
    type Ok;
    type Err;

    // Required method
    fn context_with<E, C>(self, f: impl FnOnce() -> C) -> Result<Self::Ok, E>
       where C: IntoError<E>,
             Self::Err: Into<C::Source>;

    // Provided method
    fn context<E, C>(self, context: C) -> Result<Self::Ok, E>
       where C: IntoError<E>,
             Self::Err: Into<C::Source> { ... }
}

Required Associated Types§

Required Methods§

Source

fn context_with<E, C>(self, f: impl FnOnce() -> C) -> Result<Self::Ok, E>
where C: IntoError<E>, Self::Err: Into<C::Source>,

Provided Methods§

Source

fn context<E, C>(self, context: C) -> Result<Self::Ok, E>
where C: IntoError<E>, Self::Err: Into<C::Source>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> WithContext for Option<T>

Source§

type Ok = T

Source§

type Err = NoneSource

Source§

fn context_with<E, C>(self, f: impl FnOnce() -> C) -> Result<T, E>
where C: IntoError<E>, NoneSource: Into<C::Source>,

Source§

impl<T, Err> WithContext for Result<T, Err>

Source§

type Ok = T

Source§

type Err = Err

Source§

fn context_with<E, C>(self, f: impl FnOnce() -> C) -> Result<T, E>
where C: IntoError<E>, Err: Into<C::Source>,

Implementors§