[][src]Trait tracing_unwrap::OptionExt

pub trait OptionExt<T> {
    fn unwrap_or_log(self) -> T;
fn expect_or_log(self, msg: &str) -> T;
fn unwrap_none_or_log(self)
    where
        T: Debug
;
fn expect_none_or_log(self, msg: &str)
    where
        T: Debug
; }

Extension trait for Option types.

Required methods

fn unwrap_or_log(self) -> T

Moves the value v out of the Option<T> if it is [Some(v)].

In general, because this function may panic, its use is discouraged. Instead, prefer to use pattern matching and handle the None case explicitly.

Panics

Panics if the self value equals None, logging an error message to a tracing::Subscriber at an [ERROR] level.

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

Unwraps an option, yielding the content of a Some.

Panics

Panics if the value is a None, logging the passed message to a tracing::Subscriber at an [ERROR] level.

fn unwrap_none_or_log(self) where
    T: Debug

Unwraps an option, expecting None and returning nothing.

Panics

Panics if the value is a Some, logging a message derived from the Some's value to a tracing::Subscriber at an [ERROR] level.

fn expect_none_or_log(self, msg: &str) where
    T: Debug

Unwraps an option, expecting None and returning nothing.

Panics

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

Loading content...

Implementations on Foreign Types

impl<T> OptionExt<T> for Option<T>[src]

Loading content...

Implementors

Loading content...