macro_rules! extel_assert {
($cond:expr) => { ... };
($cond:expr, $err:expr) => { ... };
($cond:expr, $err_fmt:expr, $($arg:expr),+) => { ... };
}Expand description
Assert if a given condition is true/false. If the condition is true, call the pass macro,
else call the fail macro.
The fail macro can contain the following messages depending on which arm of the macro is used:
- A default message such as “[condition] assertion failed.”
- A custom error message.
- A custom format message that can take variable arguments.
This assertion is not like Rust’s assert macro, and should not panic unless the given
condition or format arguments can panic. This macro returns an
ExtelResult.
§Example
use extel::extel_assert;
let (x, y, z) = (1, 1, 2);
// Resulting passes and error messages
extel_assert!(x == y); // passes -- no error message
extel_assert!(x == z); // "[x == z] assertion failed"
extel_assert!(x == z, "z was not 1!"); // "z was not 1!"
extel_assert!(y == z, "y = {}, z = {}", y, z); // "y = 1, z = 2"