We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4bd32cf commit e74d5beCopy full SHA for e74d5be
src/libcore/intrinsics.rs
@@ -603,8 +603,23 @@ extern "rust-intrinsic" {
603
/// cast to a `u64`; if `T` has no discriminant, returns 0.
604
pub fn discriminant_value<T>(v: &T) -> u64;
605
606
+ /// Hints to the compiler that a branch is likely to be taken. Returns the value
607
+ /// passed to it. In order for the hint to take effect, it should be used as follows:
608
+ ///
609
+ /// ```
610
+ /// unsafe fn foo(a: i32, b: i32) -> i32 {
611
+ /// if likely(a == b) {
612
+ /// 1
613
+ /// } else {
614
+ /// 2
615
+ /// }
616
617
618
#[cfg(not(stage0))]
619
pub fn likely(v: bool) -> bool;
620
+
621
+ /// Hints to the compiler that a branch is not likely to be taken. See `likely` for
622
+ /// more details
623
624
pub fn unlikely(v: bool) -> bool;
625
}
0 commit comments