Function branches::assume

source ·
pub unsafe fn assume(b: bool)
Expand description

Informs the optimizer that a condition is always true.

If the condition is actually false, the behavior is undefined.

This intrinsic doesn’t generate any code. Instead, it tells the optimizer to preserve the condition for optimization passes. This can interfere with optimization of surrounding code and reduce performance, so avoid using it if the optimizer can already discover the invariant on its own or if it doesn’t enable any significant optimizations.

Safety

This intrinsic is marked unsafe because it can result in undefined behavior if the condition passed to it is false.