#[cfg(all(target_pointer_width = "64", feature = "fastmod"))]
pub fn range_map(v: u32, max: u32) -> u32 {
debug_assert_ne!(max, 0);
((v as u64 * max as u64) >> 32) as u32
}
#[cfg(not(all(target_pointer_width = "64", feature = "fastmod")))]
pub fn range_map(v: u32, max: u32) -> u32 {
v % max
}
#[cfg(test)]
mod tests {
use super::*;
use quickcheck_macros::quickcheck;
#[quickcheck]
fn test_range_map(a: u32, b: u32) -> bool {
if b == 0 {
return true;
}
let got = range_map(a, b);
(0..b).contains(&got)
}
}