Skip to main content

ResultExt

Trait ResultExt 

Source
pub trait ResultExt {
    type Ok;
    type Err;

    // Required method
    fn into_ec<F: FnOnce(Self::Err) -> ErrorCode>(
        self,
        f: F,
    ) -> Result<Self::Ok>;
}
Expand description

Extension trait for std::result::Result.

Required Associated Types§

Required Methods§

Source

fn into_ec<F: FnOnce(Self::Err) -> ErrorCode>(self, f: F) -> Result<Self::Ok>

Turns self into an ErrorCode result by calling f when self is an error.

Consider logging the error you’re turning into an ErrorCode.

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> ResultExt for Option<T>

Source§

type Ok = T

Source§

type Err = ()

Source§

fn into_ec<F: FnOnce(()) -> ErrorCode>(self, f: F) -> Result<T>

Source§

impl<T, E> ResultExt for Result<T, E>

Source§

type Ok = T

Source§

type Err = E

Source§

fn into_ec<F: FnOnce(E) -> ErrorCode>(self, f: F) -> Result<T>

Implementors§