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