Trait ResultExt

Source
pub trait ResultExt<T, E>
where E: Into<Box<dyn Error + Send + Sync>>,
{ // Required methods fn ctx<D>(self, context: D) -> Result<T, Context<D>>; fn with_ctx<D>(self, f: impl FnOnce(&E) -> D) -> Result<T, Context<D>>; }

Required Methods§

Source

fn ctx<D>(self, context: D) -> Result<T, Context<D>>

If this Result is an Err, wrap the error with context.

Source

fn with_ctx<D>(self, f: impl FnOnce(&E) -> D) -> Result<T, Context<D>>

If this Result is an Err, invoke f and wrap the error with its 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, E> for Result<T, E>
where E: Into<Box<dyn Error + Send + Sync>>,

Source§

fn ctx<D>(self, context: D) -> Result<T, Context<D>>

Source§

fn with_ctx<D>(self, f: impl FnOnce(&E) -> D) -> Result<T, Context<D>>

Implementors§