Skip to main content

Context

Trait Context 

Source
pub trait Context<T> {
    // Required methods
    fn context(self, context: impl Display) -> Result<T>;
    fn with_context<F, D>(self, f: F) -> Result<T>
       where F: FnOnce() -> D,
             D: Display;
}
Expand description

anyhow-style context extension for Result and Option.

Required Methods§

Source

fn context(self, context: impl Display) -> Result<T>

Wrap the error with additional context.

Source

fn with_context<F, D>(self, f: F) -> Result<T>
where F: FnOnce() -> D, D: Display,

Lazily wrap the error with additional context.

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, E> Context<T> for Result<T, E>
where E: Error + Send + Sync + 'static,

Source§

fn context(self, context: impl Display) -> Result<T>

Source§

fn with_context<F, D>(self, f: F) -> Result<T>
where F: FnOnce() -> D, D: Display,

Source§

impl<T> Context<T> for Option<T>

Source§

fn context(self, context: impl Display) -> Result<T>

Source§

fn with_context<F, D>(self, f: F) -> Result<T>
where F: FnOnce() -> D, D: Display,

Implementors§