update
All checks were successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
JMARyA 2024-12-30 21:49:20 +01:00
parent 00bb6f152d
commit 86dbdcf75d
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -30,3 +30,26 @@ impl<T, E: std::fmt::Debug> LogAndIgnore for Result<T, E> {
} }
} }
} }
pub trait LogNoneAndPass {
fn log_warn_none_and_pass(self, msg: impl Fn() -> String) -> Self;
fn log_err_none_and_pass(self, msg: impl Fn() -> String) -> Self;
}
impl<T> LogNoneAndPass for Option<T> {
fn log_warn_none_and_pass(self, msg: impl Fn() -> String) -> Option<T> {
if matches!(self, None) {
log::warn!("{}", msg());
}
return self;
}
fn log_err_none_and_pass(self, msg: impl Fn() -> String) -> Option<T> {
if matches!(self, None) {
log::error!("{}", msg());
}
return self;
}
}