You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
478 B
21 lines
478 B
//! Utils
|
|
|
|
/// Get a random value between these two inclusive
|
|
pub fn jitter<T>(min: T, max: T) -> T
|
|
where T: rand::distributions::uniform::SampleUniform
|
|
{
|
|
use rand::Rng;
|
|
|
|
let mut thread = rand::thread_rng();
|
|
let dist = rand::distributions::Uniform::new_inclusive(min, max);
|
|
|
|
thread.sample(dist)
|
|
}
|
|
|
|
/// Compare pointer identity
|
|
#[inline(always)] pub fn ptr_eq<T>(ptr: &T, other: &T) -> bool
|
|
{
|
|
ptr as *const T as usize ==
|
|
other as *const T as usize
|
|
}
|