ResultExt

Trait ResultExt 

Source
pub trait ResultExt<T, E: Display> {
    // Required methods
    fn log_err_or_else<F>(self, default: F) -> T
       where F: FnOnce() -> T;
    fn log_err_default(self) -> T
       where T: Default;
}
Expand description

Extension trait for Result types that provides logging capabilities

Required Methods§

Source

fn log_err_or_else<F>(self, default: F) -> T
where F: FnOnce() -> T,

Return the Ok value unchanged. In the err case, log it, and call the closure to compute the default

Source

fn log_err_default(self) -> T
where T: Default,

Return the Ok value unchanged. In the err case, log it, and return the default value

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: Display> ResultExt<T, E> for Result<T, E>

Source§

fn log_err_or_else<F>(self, default: F) -> T
where F: FnOnce() -> T,

Source§

fn log_err_default(self) -> T
where T: Default,

Implementors§