This commit is contained in:
Aleksandr 2025-06-29 11:22:50 +03:00
parent 86003436a6
commit 210e7c438b
2 changed files with 22 additions and 0 deletions

View file

@ -27,6 +27,7 @@ pub use trait_set::trait_set;
pub mod array; pub mod array;
pub mod error; pub mod error;
pub mod utils;
pub mod fut; pub mod fut;
pub mod time; pub mod time;

21
src/utils.rs Normal file
View file

@ -0,0 +1,21 @@
//! # Uncategorized useful functionality
/// Hint that this branch is cold.
#[inline(always)]
pub const fn cold<T>(v: T) -> T {
v
}
/// Indicate that this value is unlikely to be true. Hint to
/// the compiler.
#[inline(always)]
pub const fn unlikely(v: bool) -> bool {
if v { cold(true) } else { false }
}
/// Indicate that this value is likely to be true. Hint to
/// the compiler.
#[inline(always)]
pub const fn likely(v: bool) -> bool {
if v { true } else { cold(false) }
}