Crate branch_hints

source ·
Expand description

This crate provides likely and unlikely functions that work as compiler hints for branching in stable rust. They are taken directly from the hashbrown crate, all credit belongs to them. These functions enable constructions like

if likely(condition) {
    // main code
} else {
    // error handling code
}

and they should be optimized away by the compiler.

§Notes

This is a very minimal crate. If you want more comprehensive functionality, take a look at the likely_stable crate.

Functions§

  • Returns the boolean passed to it while hinting to the compiler that it is likely to be true. This function brings likely to stable Rust.
  • Returns the boolean passed to it while hinting to the compiler that it is unlikely to be true. This function brings unlikely to stable Rust.