pub trait OrErr<T, E> {
// Required methods
fn or_err(
self,
et: ErrorType,
context: &'static str,
) -> Result<T, Box<Error>>
where E: Into<Box<dyn Error + Send + Sync>>;
fn or_err_with<C, F>(
self,
et: ErrorType,
context: F,
) -> Result<T, Box<Error>>
where C: Into<ImmutStr>,
F: FnOnce() -> C,
E: Into<Box<dyn Error + Send + Sync>>;
fn explain_err<C, F>(
self,
et: ErrorType,
context: F,
) -> Result<T, Box<Error>>
where C: Into<ImmutStr>,
F: FnOnce(E) -> C;
fn or_fail(self) -> Result<T, Box<Error>>
where E: Into<Box<dyn Error + Send + Sync>>;
}
Expand description
Helper trait to chain errors with context
Required Methods§
Sourcefn or_err_with<C, F>(self, et: ErrorType, context: F) -> Result<T, Box<Error>>
fn or_err_with<C, F>(self, et: ErrorType, context: F) -> Result<T, Box<Error>>
Similar to or_err(), but takes a closure, which is useful for constructing String.
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.