Trait mz_ore::result::ResultExt

source ·
pub trait ResultExt<T, E> {
    // Required methods
    fn err_into<E2>(self) -> Result<T, E2>
       where E: Into<E2>;
    fn err_to_string_with_causes(&self) -> Option<String>
       where E: Error;
    fn map_err_to_string_with_causes(self) -> Result<T, String>
       where E: Error;
    fn infallible_unwrap(self) -> T
       where E: Into<Infallible>;
}
Available on crate feature process only.
Expand description

Extension methods for std::result::Result.

Required Methods§

source

fn err_into<E2>(self) -> Result<T, E2>
where E: Into<E2>,

Applies Into::into to a contained Err value, leaving an Ok value untouched.

source

fn err_to_string_with_causes(&self) -> Option<String>
where E: Error,

Formats an Err value as a detailed error message, preserving any context information.

This is equivalent to format!("{}", err.display_with_causes()), except that it’s easier to type.

source

fn map_err_to_string_with_causes(self) -> Result<T, String>
where E: Error,

Maps a Result<T, E> to Result<T, String> by converting the Err result into a string, along with the chain of source errors, if any.

source

fn infallible_unwrap(self) -> T
where E: Into<Infallible>,

Safely unwraps a Result<T, Infallible>, where Infallible is a type that represents when an error cannot occur.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

source§

fn err_into<E2>(self) -> Result<T, E2>
where E: Into<E2>,

source§

fn err_to_string_with_causes(&self) -> Option<String>
where E: Error,

source§

fn map_err_to_string_with_causes(self) -> Result<T, String>
where E: Error,

source§

fn infallible_unwrap(self) -> T
where E: Into<Infallible>,

Implementors§