Go to file
Stjepan Glavina 76cd760762 Initial commit 2020-05-27 18:18:29 +02:00
examples Initial commit 2020-05-27 18:18:29 +02:00
src Initial commit 2020-05-27 18:18:29 +02:00
.gitignore Initial commit 2020-05-27 18:18:29 +02:00
CHANGELOG.md Initial commit 2020-05-27 18:18:29 +02:00
Cargo.toml Initial commit 2020-05-27 18:18:29 +02:00
LICENSE-APACHE Initial commit 2020-05-27 18:18:29 +02:00
LICENSE-MIT Initial commit 2020-05-27 18:18:29 +02:00
README.md Initial commit 2020-05-27 18:18:29 +02:00

README.md

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.