ErrorOps

Trait ErrorOps 

Source
pub trait ErrorOps<E>: WithError<E> {
    // Required methods
    fn recover<F>(self, recovery: F) -> Self
       where F: FnOnce(E) -> Self,
             Self: Sized;
    fn bimap_result<B, F, SuccessF, ErrorF>(
        self,
        success_f: SuccessF,
        error_f: ErrorF,
    ) -> Result<B, F>
       where SuccessF: FnOnce(Self::Success) -> B,
             ErrorF: FnOnce(E) -> F,
             Self: Sized;
}
Expand description

Operations for error recovery and bidirectional mapping.

Required Methods§

Source

fn recover<F>(self, recovery: F) -> Self
where F: FnOnce(E) -> Self, Self: Sized,

Attempts to recover from an error using the provided recovery function.

Source

fn bimap_result<B, F, SuccessF, ErrorF>( self, success_f: SuccessF, error_f: ErrorF, ) -> Result<B, F>
where SuccessF: FnOnce(Self::Success) -> B, ErrorF: FnOnce(E) -> F, Self: Sized,

Maps both success and error cases simultaneously.

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

Source§

fn recover<F>(self, recovery: F) -> Self
where F: FnOnce(E) -> Self,

Source§

fn bimap_result<B, F, SuccessF, ErrorF>( self, success_f: SuccessF, error_f: ErrorF, ) -> Result<B, F>
where SuccessF: FnOnce(T) -> B, ErrorF: FnOnce(E) -> F,

Implementors§