n0_error

Trait StackResultExt

Source
pub trait StackResultExt<T, E> {
    // Required methods
    fn context(self, context: impl Display) -> Result<T, AnyError>;
    fn with_context<F, C>(self, context: F) -> Result<T, AnyError>
       where F: FnOnce(&E) -> C,
             C: Display;
}
Expand description

Provides extension methods to add context to StackErrors.

Required Methods§

Source

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

Wraps the result’s error value with additional context.

Source

fn with_context<F, C>(self, context: F) -> Result<T, AnyError>
where F: FnOnce(&E) -> C, C: Display,

Wraps the result’s error value with lazily-evaluated additional context.

The context closure is only invoked if an error occurs.

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: StackError + 'static> StackResultExt<T, E> for Result<T, E>

Source§

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

Source§

fn with_context<F, C>(self, context: F) -> Result<T, AnyError>
where F: FnOnce(&E) -> C, C: Display,

Implementors§