pub trait ErrorContext: Sealed {
// Required methods
fn context<C: Display>(self, context: C) -> Self;
fn with_context<C: Display>(self, f: impl FnOnce(&Error) -> C) -> Self;
}
Expand description
Provides the context
method for Error
and Result<T, Error>
.
Required Methods§
Sourcefn context<C: Display>(self, context: C) -> Self
fn context<C: Display>(self, context: C) -> Self
Wraps the error value with additional context.
Sourcefn with_context<C: Display>(self, f: impl FnOnce(&Error) -> C) -> Self
fn with_context<C: Display>(self, f: impl FnOnce(&Error) -> C) -> Self
Wrap the error value with additional context that is evaluated lazily only once an error does occur.
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.