Skip to main content

StdContextExt

Trait StdContextExt 

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

Adds .context(..) / .with_context(..) to a Result carrying any foreign std::error::Error, converting it to an Error::Internal along the way.

Required Methods§

Source

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

Converts the foreign error to Error and attaches context.

Source

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

Converts the foreign error to Error and attaches a lazily-built context message.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T, E: StdError + Send + Sync + 'static> StdContextExt<T, E> for Result<T, E>