anyhow-std 0.1.4

Wrap std APIs with anyhow error context.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
pub fn assert_error_desc_eq<T>(res: anyhow::Result<T>, expected: &str) {
    let error = format!("{:#}", res.err().unwrap());
    assert_eq!(error, expected.trim_end());
}

pub fn err_str<T>(s: &str) -> Result<T, String> {
    Err(s.to_string())
}

pub fn stringify_error<T>(res: anyhow::Result<T>) -> Result<T, String> {
    res.map_err(|e| format!("{:#}", e))
}