mirror of
https://github.com/hexedtech/codemp.git
synced 2024-10-23 02:09:20 +02:00
16 lines
274 B
Rust
16 lines
274 B
Rust
|
use tracing::warn;
|
||
|
|
||
|
pub trait IgnorableError {
|
||
|
fn unwrap_or_log(self, msg: &str);
|
||
|
}
|
||
|
|
||
|
impl<T, E> IgnorableError for Result<T, E>
|
||
|
where E : std::fmt::Display {
|
||
|
fn unwrap_or_log(self, msg: &str) {
|
||
|
match self {
|
||
|
Ok(_) => {},
|
||
|
Err(e) => warn!("{}: {}", msg, e),
|
||
|
}
|
||
|
}
|
||
|
}
|