1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
pub(crate) mod parse;
pub(crate) mod prelude;
pub use self::parse::FromElem;
use std::fmt::Display;
pub trait ResultLogExt<T, E> {
fn ok_warn(self) -> Option<T>;
fn ok_error(self) -> Option<T>;
}
impl<T, E> ResultLogExt<T, E> for Result<T, E>
where
E: Display,
{
fn ok_warn(self) -> Option<T> {
match self {
Ok(x) => Some(x),
Err(e) => {
log::warn!("{}", e);
None
}
}
}
fn ok_error(self) -> Option<T> {
match self {
Ok(x) => Some(x),
Err(e) => {
log::error!("{}", e);
None
}
}
}
}