#[cfg(feature = "impls")]
use crate::{self as plog, info, ok, warn};
use std::fmt::{Debug, Display};
pub trait OptionLog<T> {
fn log(self, _: T) -> Self;
fn show_none(self, _: T) -> Self;
fn show_some(self, _: T) -> Self;
}
impl<T: Debug, U: Display> OptionLog<U> for Option<T> {
fn log(self, _name: U) -> Self {
#[cfg(feature = "impls")]
match self {
Some(ref x) => ok!("{_name} has {x:?}"),
None => warn!("{_name} is empty"),
};
self
}
fn show_none(self, _name: U) -> Self {
#[cfg(feature = "impls")]
if let None = self {
info!("{_name} is empty");
}
self
}
fn show_some(self, _name: U) -> Self {
#[cfg(feature = "impls")]
if let Some(ref x) = self {
info!("{_name} has {x:?}");
}
self
}
}