Skip to main content

assert_true

Macro assert_true 

Source
macro_rules! assert_true {
    ($condition:expr) => { ... };
    ($condition:expr, $rest:tt) => { ... };
}
Expand description

Asserts that a given condition is true.

This macro is similar to the standard assert! macro but links to the seed printing feature in case of failure, which can help with debugging tests that involve randomness.

§Parameters

  • $condition: The boolean condition to assert.
  • $msg: (optional) Custom failure message. Supports formatting arguments.

§Panics

Panics if the condition is false, printing any seeds used in the test thread so far

§Examples

assert_true!(1 + 1 == 2, "Math is broken!");