FallbackIf

Trait FallbackIf 

Source
pub trait FallbackIf<T, E> {
    // Required method
    fn fallback_if<P, F, V>(
        self,
        predicate: P,
        f: F,
        alternative: V,
    ) -> Result<T, E>
       where P: Into<bool>,
             F: FnOnce(V) -> Result<T, E>;
}

Required Methods§

Source

fn fallback_if<P, F, V>( self, predicate: P, f: F, alternative: V, ) -> Result<T, E>
where P: Into<bool>, F: FnOnce(V) -> Result<T, E>,

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> FallbackIf<T, E> for Result<T, E>

Source§

fn fallback_if<P, F, V>( self, predicate: P, f: F, alternative: V, ) -> Result<T, E>
where P: Into<bool>, F: FnOnce(V) -> Result<T, E>,

Fallback to an alternative when a result produces an error and the predicate evaluates to true, otherwise keep the current result

Implementors§