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§
Sourcefn context<C, E2>(self, ctx: C) -> Result<T, E2>where
C: ErrorContext<Err = E2, Source = E1>,
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.
Sourcefn with_context<C, E2, F>(self, f: F) -> Result<T, E2>
fn with_context<C, E2, F>(self, f: F) -> Result<T, E2>
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.