Skip to main content

get_random_integer

Function get_random_integer 

Source
pub fn get_random_integer<T, R>(min: T, max: T) -> R
where T: TryInto<u64>, R: RandomCast,
Expand description

Generate a random integer value in the given range (min, max) inclusive.

Accepts signed, unsigned, and platform-specific integer types for boundaries, and automatically casts the result to the inferred numeric return type.

ยงExamples

use wallswitch::get_random_integer;

let angle: f64 = get_random_integer(0, 359);
let idx: usize = get_random_integer(0, 10);
let iter: u32 = get_random_integer(300, 990);