mz_ore::result

Trait 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.

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>

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§