Skip to main content

safety_assert

Macro safety_assert 

Source
macro_rules! safety_assert {
    ($($arg:tt)*) => { ... };
}
Expand description

Safety assertion guarding unsafe preconditions and internal invariants.

A failing safety assertion indicates a bug in this library, never a runtime or input condition; it is not a hardening check. The checks run only in debug builds, and only while the (default-on) safety_assertions feature is enabled — i.e. all(debug_assertions, feature = "safety_assertions"). Release builds never run them, and disabling the feature (--no-default-features) drops them from debug builds too.

Like debug_write!/debug_expect!, the feature = "safety_assertions" cfg resolves at the call site, so every crate invoking this macro must declare the (default-on) safety_assertions feature (forwarding into core).