std::assert! []

macro_rules! assert {
    ( $ cond : expr ) => { ... };
    (
$ cond : expr , $ ( $ arg : tt ) + ) => { ... };
}

Ensure that a boolean expression is true at runtime.

This will invoke the panic! macro if the provided expression cannot be evaluated to true at runtime.

This macro has a second version, where a custom panic message can be provided.

Examples

// the panic message for these assertions is the stringified value of the
// expression given.
assert!(true);

fn some_computation() -> bool { true } // a very simple function

assert!(some_computation());

// assert with a custom message
let x = true;
assert!(x, "x wasn't true!");

let a = 3; let b = 27;
assert!(a + b == 30, "a = {}, b = {}", a, b);