Trait ResultExt

Source
pub trait ResultExt<T> {
    // Required methods
    fn context<S: ToString>(self, ctx: S) -> Result<T>;
    fn with_context<S: ToString, F: FnOnce() -> S>(self, ctx_fn: F) -> Result<T>;
}
Expand description

Extension methods to the Result type.

Required Methods§

Source

fn context<S: ToString>(self, ctx: S) -> Result<T>

Adds some context to the error.

Source

fn with_context<S: ToString, F: FnOnce() -> S>(self, ctx_fn: F) -> Result<T>

Adds context to the error, evaluating the context function only if there is an Err.

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.

Implementations on Foreign Types§

Source§

impl<T, E> ResultExt<T> for Result<T, E>
where E: Error + Send + 'static,

Source§

fn context<S: ToString>(self, ctx: S) -> Result<T>

Source§

fn with_context<S: ToString, F: FnOnce() -> S>(self, ctx_fn: F) -> Result<T>

Implementors§