ResultExt

Trait ResultExt 

Source
pub trait ResultExt<T, E1> {
    // Required methods
    fn context<C, E2>(self, ctx: C) -> Result<T, E2>
       where C: ErrorContext<Err = E2, Source = E1>;
    fn with_context<C, E2, F>(self, f: F) -> Result<T, E2>
       where F: FnOnce(&E1) -> C,
             C: ErrorContext<Err = E2, Source = E1>;
}
Expand description

Extension trait for Result which adds useful methods to use ErrorContexts.

Required Methods§

Source

fn context<C, E2>(self, ctx: C) -> Result<T, E2>
where C: ErrorContext<Err = E2, Source = E1>,

Add the given context to the error of this result.

Source

fn with_context<C, E2, F>(self, f: F) -> Result<T, E2>
where F: FnOnce(&E1) -> C, C: ErrorContext<Err = E2, Source = E1>,

Add the given context to the error of this result, lazily.

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, E1> ResultExt<T, E1> for Result<T, E1>

Source§

fn context<C, E2>(self, ctx: C) -> Result<T, E2>
where C: ErrorContext<Err = E2, Source = E1>,

Source§

fn with_context<C, E2, F>(self, f: F) -> Result<T, E2>
where F: FnOnce(&E1) -> C, C: ErrorContext<Err = E2, Source = E1>,

Implementors§