Module mz_ore::assert

source ·
Available on crate feature test only.
Expand description

Assertion utilities.

§Soft assertions

Soft assertions are like debug assertions, but they can be toggled on and off at runtime in a release build.

They are useful in two scenarios:

  • When a failed assertion should result in a log message rather a process crash.
  • When evaluating the condition is too expensive to evaluate in production deployments.

When soft assertions are disabled, the performance cost of each assertion is one branch on an atomic.

Ore provides the following macros to make soft assertions:

The _or_log variants should be used by default, as they allow us to find failed condition checks in production. The _no_log variants are silent in production and should only be used when performance considerations prohibit the use of the logging variants.

Due to limitations in Rust, these macros are exported at the crate root.

Statics§