OptionExt

Trait OptionExt 

Source
pub trait OptionExt<T> {
    // Required methods
    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;
}
Expand description

Extension trait for Option types.

Required Methods§

Source

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.

Source

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.

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl<T> OptionExt<T> for Option<T>

Source§

fn unwrap_or_log(self, log: &Logger) -> T

Source§

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

Source§

fn unwrap_none_or_log(self, log: &Logger)
where T: Debug,

Source§

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

Implementors§