Expand description
Hints to compiler that affects how code should be emitted or optimized.
Hints may be compile time or runtime.
Functions§
- assert_
unchecked ⚠ - Makes asoundness promise to the compiler that
condholds. - black_
box - An identity function thathints to the compiler to be maximally pessimistic about what
black_boxcould do. - select_
unpredictable - Returns either
true_valorfalse_valdepending on the value ofcondition, with a hint to the compiler thatconditionis unlikely to becorrectly predicted by a CPU’s branch predictor. - spin_
loop - Emits a machine instruction to signal the processor that it is running ina busy-wait spin-loop (“spin lock”).
- unreachable_
unchecked ⚠ - Informs the compiler that the site which is calling this function is notreachable, possibly enabling further optimizations.
- cold_
path Experimental - Hints to the compiler that given path is cold, i.e., unlikely to be taken. The compiler maychoose to optimize paths that are not cold at the expense of paths that are cold.
- likely
Experimental - Hints to the compiler that a branch condition is likely to be true.Returns the value passed to it.
- must_
use Experimental - An identity function that causes an
unused_must_usewarning to betriggered if the given value is not used (returned, stored in a variable,etc) by the caller. - unlikely
Experimental - Hints to the compiler that a branch condition is unlikely to be true.Returns the value passed to it.