pub trait ErrorContext<T: Display> {
// Required method
fn context(self, msg: T) -> Self;
// Provided method
fn with_context<F>(self, f: F) -> Self
where F: FnOnce() -> T,
Self: Sized { ... }
}Required Methods§
Provided Methods§
Sourcefn with_context<F>(self, f: F) -> Self
fn with_context<F>(self, f: F) -> Self
Attach context lazily, so the message is only built when there is actually an error to attach it to.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T, M> ErrorContext<M> for Result<T, DecodeError>where
M: Display,
impl<T, M> ErrorContext<M> for Result<T, DecodeError>where
M: Display,
Source§fn with_context<F>(self, f: F) -> Result<T, DecodeError>where
F: FnOnce() -> M,
fn with_context<F>(self, f: F) -> Result<T, DecodeError>where
F: FnOnce() -> M,
Only render the error on the Err case