#random #rand #no-std

no-std picorand

A zero-dependency, no_std-compatible, easily extendable library intended for fast random number generation using the WyRand PRNG with a pico-sized footprint

4 releases

0.1.2 Feb 7, 2023
0.1.1 Dec 28, 2020
0.1.0 Dec 27, 2020
0.0.0 Dec 21, 2020

#2393 in Algorithms


Used in 2 crates

MIT license

8KB
115 lines

Current Crates.io Version docs-rs

picorand

A zero-dependency, no_std-compatible, easily extendable library intended for fast random number generation using the WyRand PRNG with a pico-sized footprint.

To add to your Cargo.toml:

picorand = "0.1.2"

Example

use picorand::{PicoRandGenerate, WyRand, RNG};

fn main() {
    let mut rng = RNG::<WyRand, u16>::new(0xDEADBEEF);

    // Generate in implicit range
    let mut generated = rng.generate();
    assert!(generated >= u16::MIN || generated < u16::MAX);

    // Generate in explicit range
    generated = rng.generate_range(0xC0, 0xDE);
    assert!(generated >= 0xC0 || generated < 0xDE);
}

No runtime deps