Function likely
const fn likely(b: bool) -> bool
Hints to the compiler that a branch condition is likely to be true. Returns the value passed to it.
It can be used with if or boolean match expressions.
When used outside of a branch condition, it may still influence a nearby branch, but probably will not have any effect.
It can also be applied to parts of expressions, such as likely(a) && unlikely(b), or to
compound expressions, such as likely(a && b). When applied to compound expressions, it has
the following effect:
likely(!a) => !unlikely(a)
likely(a && b) => likely(a) && likely(b)
likely(a || b) => a || likely(b)
See also the function [cold_path()] which may be more appropriate for idiomatic Rust code.
Examples
use likely;