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§
Sourcefn inspect_or_log(self, msg: &str) -> Self
fn inspect_or_log(self, msg: &str) -> Self
Log with log::Level::Info if the value is Err or None.
Sourcefn inspect_or_log_with<M: Display>(self, f: impl FnOnce() -> M) -> Self
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.
Sourcefn unwrap_or_default_log(self, msg: &str) -> Twhere
T: Default,
fn unwrap_or_default_log(self, msg: &str) -> Twhere
T: Default,
Log with log::Level::Warn if the value is Err or None,
and return a default value of T.
Sourcefn unwrap_or_default_log_with<M: Display>(self, f: impl FnOnce() -> M) -> Twhere
T: Default,
fn unwrap_or_default_log_with<M: Display>(self, f: impl FnOnce() -> M) -> Twhere
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.
Sourcefn unwrap_or_log(self, msg: &str) -> T
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.
Sourcefn unwrap_or_log_with<M: Display>(self, f: impl FnOnce() -> M) -> T
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.