Skip to main content

ResultExt

Trait ResultExt 

Source
pub trait ResultExt<T>: Sealed {
    // Required methods
    fn with_kind(self, kind: ErrorKind) -> Result<T>;
    fn with_context<C>(self, kind: ErrorKind, message: C) -> Result<T>
       where Self: Sized,
             C: Into<Cow<'static, str>>;
    fn with_context_fn<F, C>(self, kind: ErrorKind, f: F) -> Result<T>
       where Self: Sized,
             F: FnOnce() -> C,
             C: Into<Cow<'static, str>>;
}
Expand description

Extension methods for std::result::Result.

Required Methods§

Source

fn with_kind(self, kind: ErrorKind) -> Result<T>

Create an Error containing another error with an ErrorKind.

Source

fn with_context<C>(self, kind: ErrorKind, message: C) -> Result<T>
where Self: Sized, C: Into<Cow<'static, str>>,

Create an Error containing another error with an ErrorKind and message.

Source

fn with_context_fn<F, C>(self, kind: ErrorKind, f: F) -> Result<T>
where Self: Sized, F: FnOnce() -> C, C: Into<Cow<'static, str>>,

Create an Error containing another error with an ErrorKind and a function that returns a message.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T, E> ResultExt<T> for Result<T, E>
where E: Error + Send + Sync + 'static,

Source§

fn with_kind(self, kind: ErrorKind) -> Result<T>

Source§

fn with_context<C>(self, kind: ErrorKind, message: C) -> Result<T>
where Self: Sized, C: Into<Cow<'static, str>>,

Source§

fn with_context_fn<F, C>(self, kind: ErrorKind, f: F) -> Result<T>
where Self: Sized, F: FnOnce() -> C, C: Into<Cow<'static, str>>,

Implementors§