pub trait LogAndIgnore { fn log_err_and_ignore(self, msg: &str); fn log_warn_and_ignore(self, msg: &str); } impl LogAndIgnore for Result { /// Handles the result by ignoring and logging it if it contains an error. /// /// If the result is `Ok`, does nothing. /// If the result is `Err(e)`, logs the message provided (`msg`) along with the error as error. fn log_err_and_ignore(self, msg: &str) { match self { Ok(_) => {} Err(e) => { log::error!("{msg} : {:?}", e); } } } /// Handles the result by ignoring and logging it if it contains an error. /// /// If the result is `Ok`, does nothing. /// If the result is `Err(e)`, logs the message provided (`msg`) along with the error as warning. fn log_warn_and_ignore(self, msg: &str) { match self { Ok(_) => {} Err(e) => { log::warn!("{msg} : {:?}", e); } } } }