TryLog

Trait TryLog 

Source
pub trait TryLog<T, R: Debug> {
    // Required methods
    fn inspect_or_log(self, msg: &str) -> Self;
    fn inspect_or_log_with<M: Display>(self, f: impl FnOnce() -> M) -> Self;
    fn unwrap_or_default_log(self, msg: &str) -> T
       where T: Default;
    fn unwrap_or_default_log_with<M: Display>(self, f: impl FnOnce() -> M) -> T
       where T: Default;
    fn unwrap_or_log(self, msg: &str) -> T;
    fn unwrap_or_log_with<M: Display>(self, f: impl FnOnce() -> M) -> T;
}
Expand description

This trait provides the or-log methods.

Required Methods§

Source

fn inspect_or_log(self, msg: &str) -> Self

Log with log::Level::Info if the value is Err or None.

Source

fn inspect_or_log_with<M: Display>(self, f: impl FnOnce() -> M) -> Self

Log with log::Level::Info if the value is Err or None.

The log message is returned by f.

Source

fn unwrap_or_default_log(self, msg: &str) -> T
where T: Default,

Log with log::Level::Warn if the value is Err or None, and return a default value of T.

Source

fn unwrap_or_default_log_with<M: Display>(self, f: impl FnOnce() -> M) -> T
where T: Default,

Log with log::Level::Warn if the value is Err or None, and return a default value of T.

The log message is returned by f.

Source

fn unwrap_or_log(self, msg: &str) -> T

Log with log::Level::Error if the value is Err or None, and panic with the same error message.

Source

fn unwrap_or_log_with<M: Display>(self, f: impl FnOnce() -> M) -> T

Log with log::Level::Error if the value is Err or None, and panic with the same error message.

The log message is returned by f.

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.

Implementors§

Source§

impl<T, R: Debug, Tr: Try<Output = T, Residual = R>> TryLog<T, R> for Tr