utils
This commit is contained in:
parent
86003436a6
commit
210e7c438b
2 changed files with 22 additions and 0 deletions
|
@ -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
21
src/utils.rs
Normal 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) }
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue