pub trait ResultExt<T, E> {
// Required methods
fn context<C>(self, context: C) -> Result<T, ContextError<E, C>>;
fn with_context<C, F>(self, f: F) -> Result<T, ContextError<E, C>>
where F: FnOnce() -> C;
}
Expand description
Extension trait for Result types to add context to errors
Required Methods§
Sourcefn context<C>(self, context: C) -> Result<T, ContextError<E, C>>
fn context<C>(self, context: C) -> Result<T, ContextError<E, C>>
Adds context to the error variant of the Result
Sourcefn with_context<C, F>(self, f: F) -> Result<T, ContextError<E, C>>where
F: FnOnce() -> C,
fn with_context<C, F>(self, f: F) -> Result<T, ContextError<E, C>>where
F: FnOnce() -> C,
Adds context to the error variant using a closure that is only called on error
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.