pub trait ResultExt<T, E>: Sized {
// Required methods
fn bind<R>(self, f: impl FnOnce(T) -> Result<R, E>) -> Result<R, E>;
fn swap(self) -> Result<E, T>;
fn recover<R>(self, f: impl FnOnce(E) -> Result<T, R>) -> Result<T, R>;
fn try_perform(self, f: impl FnOnce(&T) -> Result<(), E>) -> Result<T, E>;
fn perform_err(self, f: impl FnOnce(&E)) -> Result<T, E>;
fn perform(self, f: impl FnOnce(&T)) -> Result<T, E>;
fn perform_mut(self, f: impl FnOnce(&mut T)) -> Result<T, E>;
fn filter(
self,
pred: impl FnOnce(&T) -> bool,
on_fail: impl FnOnce(&T) -> E,
) -> Result<T, E>;
// Provided methods
fn tupled<R>(self, f: impl FnOnce(&T) -> Result<R, E>) -> Result<(T, R), E> { ... }
fn two<B>(a: Result<T, E>, b: Result<B, E>) -> Result<(T, B), E> { ... }
}Expand description
Extensions to Result
Required Methods§
Sourcefn bind<R>(self, f: impl FnOnce(T) -> Result<R, E>) -> Result<R, E>
fn bind<R>(self, f: impl FnOnce(T) -> Result<R, E>) -> Result<R, E>
Alias for [Result.and_then]
Sourcefn recover<R>(self, f: impl FnOnce(E) -> Result<T, R>) -> Result<T, R>
fn recover<R>(self, f: impl FnOnce(E) -> Result<T, R>) -> Result<T, R>
Allows turning an Err back into Ok by binding on the Err variant
Sourcefn try_perform(self, f: impl FnOnce(&T) -> Result<(), E>) -> Result<T, E>
fn try_perform(self, f: impl FnOnce(&T) -> Result<(), E>) -> Result<T, E>
Attempt to perform some fallible IO
Sourcefn perform_err(self, f: impl FnOnce(&E)) -> Result<T, E>
fn perform_err(self, f: impl FnOnce(&E)) -> Result<T, E>
Perform some IO when this Result is Err
Sourcefn perform_mut(self, f: impl FnOnce(&mut T)) -> Result<T, E>
fn perform_mut(self, f: impl FnOnce(&mut T)) -> Result<T, E>
Perform some IO mutating the data contained in the Ok of this Result
Provided Methods§
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.