re_log

Trait ResultExt

Source
pub trait ResultExt<T, E> {
    // Required methods
    fn ok_or_log_error(self) -> Option<T>;
    fn ok_or_log_error_once(self) -> Option<T>;
    fn warn_on_err_once(self, msg: impl Display) -> Option<T>;
    fn unwrap_debug_or_log_error(self) -> Option<T>;
}

Required Methods§

Source

fn ok_or_log_error(self) -> Option<T>

Logs an error if the result is an error and returns the result.

Source

fn ok_or_log_error_once(self) -> Option<T>

Logs an error if the result is an error and returns the result, but only once.

Source

fn warn_on_err_once(self, msg: impl Display) -> Option<T>

Log a warning if there is an Err, but only log the exact same message once.

Source

fn unwrap_debug_or_log_error(self) -> Option<T>

Unwraps in debug builds otherwise logs an error if the result is an error and returns the result.

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

Source§

fn warn_on_err_once(self, msg: impl Display) -> Option<T>

Log a warning if there is an Err, but only log the exact same message once.

Source§

fn ok_or_log_error(self) -> Option<T>

Source§

fn ok_or_log_error_once(self) -> Option<T>

Source§

fn unwrap_debug_or_log_error(self) -> Option<T>

Implementors§