pub trait OptionExt<T> {
// Required methods
fn context(self, msg: impl Display) -> Result<T>;
fn with_context<F, M>(self, f: F) -> Result<T>
where F: FnOnce() -> M,
M: Display;
}Expand description
Extension methods on Option<T>.
Required Methods§
Sourcefn context(self, msg: impl Display) -> Result<T>
fn context(self, msg: impl Display) -> Result<T>
Convert None into an anyhow::Error with the given message.
Sourcefn with_context<F, M>(self, f: F) -> Result<T>
fn with_context<F, M>(self, f: F) -> Result<T>
Like OptionExt::context but the message is lazily constructed.
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.