pub trait ResultExt<T, E>: Sized {
    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>; 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§

Alias for [Result.and_then]

Swap the Ok and Err variants

Allows turning an Err back into Ok by binding on the Err variant

Attempt to perform some fallible IO

Perform some IO when this Result is Err

Perform some IO when this Result is Ok

Perform some IO mutating the data contained in the Ok of this Result

Test the data in Ok and turn it into an Err if it doesn’t pass a predicate

Provided Methods§

Do some fallible IO that resolves in a value and combine Oks

Boolean AND

Implementations on Foreign Types§

Implementors§