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

Crate pw_assert

Crate pw_assert 

Source
Expand description

§pw_assert

pw_assert provides crash-safe assert and panic macros that route to a configured backend. This is designed for embedded systems where standard library panics might not be suitable, or where specific logging/recovery behavior is needed.

The macros in this crate are designed to be drop-in replacements for core::panic!, core::assert!, etc., and delegate to backend macros:

§Example

pw_assert::assert!(42 == 16, "Stack start is not aligned");

pw_assert::panic!("Unhandled interrupt: irq={}", 16 as u32);

pw_assert::debug_assert!(1 == 0);

pw_assert::debug_panic!("Next monotonic tick overflow");

Macros§

assert
Asserts that a condition is true.
debug_assert
Asserts that a condition is true when debug_assertions are enabled.
debug_eq
Asserts that two expressions are equal when debug_assertions are enabled.
debug_ne
Asserts that two expressions are not equal when debug_assertions are enabled.
debug_panic
Panics unconditionally when debug_assertions are enabled.
eq
Asserts that two expressions are equal (equivalent to assert_eq!).
ne
Asserts that two expressions are not equal (equivalent to assert_ne!).
panic
Panics unconditionally.