fastrand 1.0.0

A simple random number generator
Documentation

fastrand

Build License Cargo Documentation

A simple random number generator.

Easy to use but not cryptographically secure.

Examples

Flip a coin:

if fastrand::bool() {
    println!("heads");
} else {
    println!("tails");
}

Generate a random i32:

let num = fastrand::i32(..);

Choose a random element in an array:

let v = vec![1, 2, 3, 4, 5];
let i = fastrand::usize(..v.len());
let elem = v[i];

Shuffle an array:

let mut v = vec![1, 2, 3, 4, 5];
fastrand::shuffle(&mut v);

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.