Skip to main content

FallbackExt

Trait FallbackExt 

Source
pub trait FallbackExt<T, E> {
    // Required methods
    fn or_fallback(self, fallback: T) -> Result<T, E>;
    fn or_fallback_with<F: FnOnce() -> T>(self, f: F) -> Result<T, E>;
}
Expand description

Extension trait for adding fallback behavior to Results.

Required Methods§

Source

fn or_fallback(self, fallback: T) -> Result<T, E>

Return a fallback value if this result is an error.

Source

fn or_fallback_with<F: FnOnce() -> T>(self, f: F) -> Result<T, E>

Return a fallback value computed by a function if this result is an error.

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

Source§

fn or_fallback(self, fallback: T) -> Result<T, E>

Source§

fn or_fallback_with<F: FnOnce() -> T>(self, f: F) -> Result<T, E>

Implementors§