pub trait ResultExt<T, E> {
    // Required methods
    fn ok_or_log(self) -> Option<T>
       where E: Debug;
    fn unwrap_or_log(self) -> T
       where E: Debug;
    fn expect_or_log(self, msg: &str) -> T
       where E: Debug;
    fn unwrap_err_or_log(self) -> E
       where T: Debug;
    fn expect_err_or_log(self, msg: &str) -> E
       where T: Debug;
}
Expand description

Extension trait for Result types.

Required Methods§

source

fn ok_or_log(self) -> Option<T>
where E: Debug,

Converts self into an Option<T>, consuming self, and logs the error, if any, to a tracing::Subscriber at a WARN level.

source

fn unwrap_or_log(self) -> T
where E: Debug,

Unwraps a result, yielding the content of an Ok.

§Panics

Panics if the value is an Err, logging a message provided by the Err’s value to a tracing::Subscriber at an ERROR level.

source

fn expect_or_log(self, msg: &str) -> T
where E: Debug,

Unwraps a result, yielding the content of an Ok.

§Panics

Panics if the value is an Err, logging the passed message and the content of the Err to a tracing::Subscriber at an ERROR level.

source

fn unwrap_err_or_log(self) -> E
where T: Debug,

Unwraps a result, yielding the content of an Err.

§Panics

Panics if the value is an Ok, logging a message provided by the Ok’s value to a tracing::Subscriber at an ERROR level.

source

fn expect_err_or_log(self, msg: &str) -> E
where T: Debug,

Unwraps a result, yielding the content of an Err.

§Panics

Panics if the value is an Ok, logging the passed message and the content of the Ok to a tracing::Subscriber at an ERROR level.

Implementations on Foreign Types§

source§

impl<T, E> ResultExt<T, E> for Result<T, E>

source§

fn ok_or_log(self) -> Option<T>
where E: Debug,

source§

fn unwrap_or_log(self) -> T
where E: Debug,

source§

fn expect_or_log(self, msg: &str) -> T
where E: Debug,

source§

fn unwrap_err_or_log(self) -> E
where T: Debug,

source§

fn expect_err_or_log(self, msg: &str) -> E
where T: Debug,

Implementors§