Trait tracing_unwrap::OptionExt
source · pub trait OptionExt<T> {
// Required methods
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;
}
Expand description
Extension trait for Option types.
Required Methods§
sourcefn unwrap_or_log(self) -> T
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.
sourcefn expect_or_log(self, msg: &str) -> T
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.
sourcefn unwrap_none_or_log(self)where
T: Debug,
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.
sourcefn expect_none_or_log(self, msg: &str)where
T: Debug,
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.