Skip to main content

ResultExt

Trait ResultExt 

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

Extension trait for adding context to Results in async operations

Required Methods§

Source

fn context<S: Into<String>>(self, context: S) -> Result<T>

Add context to an error

Source

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

Add context to an error using a closure (lazy evaluation)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> ResultExt<T> for Result<T>