ResultExt

Trait ResultExt 

Source
pub trait ResultExt<T> {
    // Required methods
    fn context(self, ctx: impl Into<String>) -> ChieResult<T>;
    fn with_context<F>(self, f: F) -> ChieResult<T>
       where F: FnOnce() -> String;
}
Expand description

Extension trait to add context to any result

Required Methods§

Source

fn context(self, ctx: impl Into<String>) -> ChieResult<T>

Add context to an error

§Errors

Returns the error with additional context if the result is Err

Source

fn with_context<F>(self, f: F) -> ChieResult<T>
where F: FnOnce() -> String,

Add context using a closure (lazy evaluation)

§Errors

Returns the error with additional context if the result is 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.

Implementors§

Source§

impl<T> ResultExt<T> for ChieResult<T>