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

debug_assert

Macro debug_assert 

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

Asserts that a condition is true when debug_assertions are enabled.

If debug_assertions are enabled, this behaves exactly like assert! (delegating to assert_unary_backend! if the condition evaluates to false). If debug_assertions are disabled, this macro is a no-op.

debug_assertions can be enabled by setting this bazel label to True @pigweed//pw_assert/rust:debug_assertions.

§Examples

let x = 5;
pw_assert::debug_assert!(x == 5);