2021-11-30 14:30:13 +00:00
|
|
|
#[inline(always)]
|
|
|
|
#[allow(unused)]
|
|
|
|
pub const fn likely(b: bool) -> bool {
|
|
|
|
// borrowed from `likely_stable` crate
|
|
|
|
#[allow(clippy::needless_bool)]
|
2021-12-02 15:55:56 +00:00
|
|
|
if 1_i32.checked_div(if b { 1 } else { 0 }).is_some() {
|
2021-11-30 14:30:13 +00:00
|
|
|
true
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
#[allow(unused)]
|
|
|
|
pub const fn unlikely(b: bool) -> bool {
|
|
|
|
// borrowed from `likely_stable` crate
|
|
|
|
#[allow(clippy::needless_bool)]
|
2021-12-02 15:55:56 +00:00
|
|
|
if 1_i32.checked_div(if b { 0 } else { 1 }).is_none() {
|
2021-11-30 14:30:13 +00:00
|
|
|
true
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|