A lightweight psudo random number generator library for Rust featuring:
• Epoch‑seeded RNG
• Configurable Linear Congruential Generator (LCG)
• Simple API
• No external dependencies
This crate is intended for lightweight simulations, games, and experimentation where a fast and simple RNG is useful.
cargo add epoch_rnguse epoch_rng::epoch_rng::EpochRng;
fn main() {
let mut rng = EpochRng::new();
println!("u64: {}", rng.next_u64());
println!("u32: {}", rng.next_u32());
println!("f64: {}", rng.next_f64());
println!("range f64: {}", rng.gen_range(1.0, 10.0));
}use epoch_rng::epoch_rng::EpochRng;
fn main() {
let mut rng = EpochRng::new();
let mut data = [1,2,3,4,5];
rng.shuffle(&mut data);
println!("{:?}", data);
}use epoch_rng::lcg_rng::LcgRng;
fn main() {
let mut rng = LcgRng::new();
println!("{}", rng.next_u64());
}Current RNG implementations:
• EpochRng – seeded from system epoch time
• LcgRng – configurable linear congruential generator
Both support:
next_u64next_u32next_f64- range generation
- shuffling
Possible improvements:
no_stdsupport- additional algorithms (XorShift, PCG, Xoshiro)