logerr 0.2.0

Seamless error type logging
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! # Error logging for `anyhow::Result<_>`
//!
//! > Requires the `anyhow` feature!
//!
//! Uses the default debug formatting for [`anyhow::Result`][anyhow::Result].
use crate::LoggableError;

impl<T> LoggableError<T> for anyhow::Result<T> {
    fn print_error<F: Fn(&str)>(self, fun: F) -> Self {
        if let Err(ref err) = self {
            fun(&format!("{:?}", err));
        }
        self
    }
}