Macro simple_error::simple_error
source · macro_rules! simple_error { ($fmt:literal) => { ... }; ($e:expr) => { ... }; ($fmt:literal, $($arg:tt)+) => { ... }; }
Expand description
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))
}