pub trait Context<T> {
// Required methods
fn wrap_err(self, context: impl Display) -> Result<T>;
fn wrap_err_with<C>(self, context: impl FnOnce() -> C) -> Result<T>
where C: Display;
}Expand description
Extension trait that annotates foreign Results with stow-style context.
Implemented for every Result<T, E: Display>; the source error’s
Display output becomes the wrapped cause.
Required Methods§
Sourcefn wrap_err_with<C>(self, context: impl FnOnce() -> C) -> Result<T>where
C: Display,
fn wrap_err_with<C>(self, context: impl FnOnce() -> C) -> Result<T>where
C: Display,
Lazily evaluated variant of Context::wrap_err: context runs only
when self is Err.
§Errors
Returns the source error wrapped in context() when self is Err.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".