rvlib/
result.rs

1use std::fmt::Debug;
2use tracing::{error, warn};
3pub fn ignore_error<T, E>(x: Result<T, E>) -> Option<T>
4where
5    E: Debug,
6{
7    x.ok()
8}
9pub fn trace_ok_err<T, E>(x: Result<T, E>) -> Option<T>
10where
11    E: Debug,
12{
13    match x {
14        Ok(x) => Some(x),
15        Err(e) => {
16            error!("{e:?}");
17            None
18        }
19    }
20}
21pub fn trace_ok_warn<T, E>(x: Result<T, E>) -> Option<T>
22where
23    E: Debug,
24{
25    match x {
26        Ok(x) => Some(x),
27        Err(e) => {
28            warn!("{e:?}");
29            None
30        }
31    }
32}