Function rand

Source
pub fn rand() -> u32
Expand description

Returns a pseudo-random number in the range of 0 to u32::MAX.

Examples found in repository?
examples/basic.rs (line 8)
3fn main() {
4    // seed random
5    qrand::srand(12345);
6
7    // get random number from 0 to u32::MAX
8    let x = qrand::rand();
9
10    // get random number from given range
11    let x = qrand::gen_range(0., 1.);
12    assert!(x >= 0. && x < 1.);
13    println!("x={}", x);
14
15    // gen_range works for most of standard number types
16    let x: u8 = qrand::gen_range(64, 128);
17    assert!(x >= 64 && x < 128);
18    println!("x={}", x);
19}