Macro assertables::assertable
source · [−]macro_rules! assertable {
($x:expr $(,)?) => { ... };
($x:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a condition is true.
-
When true, return
Ok(()). -
Otherwise, return
Errwith a message and the values of the expressions with their debug representations.
Examples
let x = assertable!(true);
//-> Ok(())
assert_eq!(x.unwrap(), ());
let x = assertable!(false);
//-> Err("…")
// assertable failed: `assertable!(condition)`
// condition: `false`
assert_eq!(x.unwrap_err(), "assertable failed: `assertable!(condition)`\n condition: `false`".to_string());This macro has a second form where a custom message can be provided.