logging: Move all facilities to one file

This commit is contained in:
Dorota Czaplejewicz
2019-12-16 19:15:40 +00:00
parent 1237537005
commit e2b89e85f7
6 changed files with 50 additions and 42 deletions

View File

@ -189,27 +189,6 @@ impl<T> Borrow<Rc<T>> for Pointer<T> {
}
}
/// Sugar for logging errors in results
pub trait Warn {
type Value;
fn ok_warn(self, msg: &str) -> Option<Self::Value>;
}
impl<T, E: std::error::Error> Warn for Result<T, E> {
type Value = T;
fn ok_warn(self, msg: &str) -> Option<T> {
self.map_err(|e| {
eprintln!("{}: {}", msg, e);
e
}).ok()
}
}
pub trait WarningHandler {
/// Handle a warning
fn handle(&mut self, warning: &str);
}
#[cfg(test)]
mod tests {
use super::*;