Skip to main content Skip to main content
Pigweed's logo Pigweed
  1. Home
  2. Reference
  3. Rust
  4. pw_assert
  5. assert

assert

Macro assert 

Source
macro_rules! assert {
    ($condition:expr $(,)?) => { ... };
    ($condition:expr, $($args:expr),* $(,)?) => { ... };
}
Expand description

Asserts that a condition is true.

If the condition evaluates to false, this macro delegates to the backend macro assert_unary_backend!.

§Examples

let x = 5;
pw_assert::assert!(x > 0);
pw_assert::assert!(x == 5, "x should be 5, but was {}", x as i32);