Skip to content
/ alea Public

Fast and easy zero-dep random number generation.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

al-jshen/alea

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alea

Crates.io Documentation License

A zero-dependency crate for fast number generation, with a focus on ease of use (no more passing &mut rng everywhere!).

The implementation is based on wyrand, a high-quality and fast generator.

This crate is heavily inspired by fastrand. For some benchmarks, see benches.

Usage

Add the following to your Cargo.toml:

[dependencies]
alea = "0.2"

Examples

Flip a coin:

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

Generate a u64:

let u = alea::u64();

Fill a vector with random integers in some range:

let n = 1_000_000;

let mut v = vec![0; n];
for i in 0..n {
  v[i] = alea::i32_in_range(-200, 150);
}

Seed the generator to get reproducible results:

alea::set_seed(10);

About

Fast and easy zero-dep random number generation.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages