pub trait ResultExt<T, E>: Sized {
// Required methods
fn wrap_err<F, E2>(self, f: F) -> Result<T, E2>
where F: FnOnce() -> E2;
fn with_context(self, context: &'static str) -> Result<T>
where E: Into<Error>;
fn with_message(self, message: impl Into<String>) -> Result<T>
where E: Into<Error>;
}
Expand description
Extension trait for Result types
Required Methods§
Sourcefn wrap_err<F, E2>(self, f: F) -> Result<T, E2>where
F: FnOnce() -> E2,
fn wrap_err<F, E2>(self, f: F) -> Result<T, E2>where
F: FnOnce() -> E2,
Wrap an error with additional context
Sourcefn with_context(self, context: &'static str) -> Result<T>
fn with_context(self, context: &'static str) -> Result<T>
Add context to an error when converting to 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.