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§
Sourcefn err_into<E2>(self) -> Result<T, E2>where
E: Into<E2>,
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.
Sourcefn err_to_string_with_causes(&self) -> Option<String>where
E: Error,
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.
Sourcefn map_err_to_string_with_causes(self) -> Result<T, String>where
E: Error,
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.
Sourcefn infallible_unwrap(self) -> Twhere
E: Into<Infallible>,
fn infallible_unwrap(self) -> Twhere
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.