[][src]Macro simple_error::simple_error

macro_rules! simple_error {
    ($e:expr) => { ... };
    ($fmt:expr, $($arg:tt)+) => { ... };
}

Construct an ad-hoc SimpleError from a string.

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

Example

use self::simple_error::SimpleResult;

fn add_reason(r: Result<(), ()>) -> SimpleResult<()> {
    // Use with a string slice
    r.map_err(|_| simple_error!("no reason"))
}

fn add_reason_with_str(r: Result<(), ()>, s: &str) -> SimpleResult<()> {
    // Use with a formatted string
    r.map_err(|_| simple_error!("reason: {}", s))
}