std::debug_assert
Macro std::debug_assert
macro_rules! debug_assert { ( $ ( $ 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.
Like assert!
, this macro also has a second version, where a custom panic message can be provided.
Unlike assert!
, debug_assert!
statements are only enabled in non optimized builds by default. An optimized build will omit all debug_assert!
statements unless -C debug-assertions
is passed to the compiler. This makes debug_assert!
useful for checks that are too expensive to be present in a r