[][src]Trait slog_unwrap::OptionExt

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

Extension trait for Option types.

Required methods

fn unwrap_or_log(self, log: &Logger) -> 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 slog::Logger at a [Critical] level.

fn expect_or_log(self, log: &Logger, 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 slog::Logger at a [Critical] level.

fn unwrap_none_or_log(self, log: &Logger) 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 slog::Logger at a [Critical] level.

fn expect_none_or_log(self, log: &Logger, 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 slog::Logger at a [Critical] level.

Loading content...

Implementations on Foreign Types

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

Loading content...

Implementors

Loading content...