macro_rules! map_err_with {
    ($r: expr, $fmt:literal) => { ... };
    ($r: expr, $str: expr) => { ... };
    ($r: expr, $fmt:literal, $($arg:tt)+) => { ... };
}
Expand description

Map a result type error to simple error with format

It can take either just a string, or a format string with arguments.

Example

use self::simple_error::SimpleResult;

fn map_err_with_reason(r: Result<(), std::io::Error>) -> SimpleResult<()> {
    // Use with a string slice
    map_err_with!(r, "no reason")
}

fn map_err_with_reason_with_str(r: Result<(), std::io::Error>, s: &str) -> SimpleResult<()> {
    // Use with a formatted string
    map_err_with!(r, "no reason: {}", s)
}