Skip to main content

OptionPrinter

Trait OptionPrinter 

Source
pub trait OptionPrinter {
    // Required methods
    fn error_none<M: Display>(self, message: M) -> Self;
    fn warn_none<M: Display>(self, message: M) -> Self;
    fn debug_none<M: Display>(self, message: M) -> Self;
    fn info_none<M: Display>(self, message: M) -> Self;
}
Expand description

A helper trait to log when an option is None. The logging functions will track the caller’s callsite. For a chain of calls A -> B -> C -> OptionPrinter, the topmost function without #[track_caller] is deemed the callsite.

Required Methods§

Source

fn error_none<M: Display>(self, message: M) -> Self

Source

fn warn_none<M: Display>(self, message: M) -> Self

Source

fn debug_none<M: Display>(self, message: M) -> Self

Source

fn info_none<M: Display>(self, message: M) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> OptionPrinter for Option<T>

Source§

fn error_none<M: Display>(self, message: M) -> Self

If self is None, prints out the message to tracing::error.

Source§

fn warn_none<M: Display>(self, message: M) -> Self

If self is None, prints out the message to tracing::warn.

Source§

fn debug_none<M: Display>(self, message: M) -> Self

If self is None, prints out the message to tracing::debug.

Source§

fn info_none<M: Display>(self, message: M) -> Self

If self is None, prints out the message to tracing::info.

Implementors§