ResultExt

Trait ResultExt 

Source
pub trait ResultExt<T, E> {
    // Required methods
    fn ctx<C: IntoErrorContext>(
        self,
        msg: C,
    ) -> Result<T, Box<ComposableError<E>>>;
    fn ctx_with<F>(self, f: F) -> Result<T, Box<ComposableError<E>>>
       where F: FnOnce() -> String;
}
Expand description

Extension trait for ergonomic context addition to Result types.

Required Methods§

Source

fn ctx<C: IntoErrorContext>(self, msg: C) -> Result<T, Box<ComposableError<E>>>

Adds a static context message to the error.

Source

fn ctx_with<F>(self, f: F) -> Result<T, Box<ComposableError<E>>>
where F: FnOnce() -> String,

Adds a lazily-evaluated context message to the error.

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, E> for Result<T, E>

Source§

fn ctx<C: IntoErrorContext>(self, msg: C) -> Result<T, Box<ComposableError<E>>>

Source§

fn ctx_with<F>(self, f: F) -> Result<T, Box<ComposableError<E>>>
where F: FnOnce() -> String,

Implementors§