Skip to main content

ResultExt

Trait ResultExt 

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

Result extension trait for adding context to errors

Required Methods§

Source

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

Add context to an error result

Source

fn context(self, msg: &'static str) -> Result<T>

Add static context to an error result

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: Into<ValknutError>,

ResultExt implementation for results with errors convertible to ValknutError.

Source§

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

Adds dynamic context to an error result using a closure.

Source§

fn context(self, msg: &'static str) -> Result<T>

Adds static context to an error result.

Implementors§