[][src]Macro assert2::assert

macro_rules! assert {
    ($($tokens:tt)*) => { ... };

Assert that an expression evaluates to true or matches a pattern.

Use a let expression to test an expression against a pattern: assert!(let pattern = expr). For other tests, just give a boolean expression to the macro: assert!(1 + 2 == 2).

If the expression evaluates to false or if the pattern doesn't match, an assertion failure is printed and the macro panics instantly.

Use check! if you still want further checks to be executed.

Custom messages

You can pass additional arguments to the macro. These will be used to print a custom message in addition to the normal message.

assert!(3 * 4 == 12, "Oh no, math is broken! 1 + 1 == {}", 1 + 1);