Crates.io | picorand |
lib.rs | picorand |
version | 0.1.2 |
source | src |
created_at | 2020-12-21 06:54:33.686889 |
updated_at | 2023-02-07 04:55:24.617474 |
description | A zero-dependency, no_std-compatible, easily extendable library intended for fast random number generation using the WyRand PRNG with a pico-sized footprint. |
homepage | |
repository | https://github.com/inspier/picorand |
max_upload_size | |
id | 325121 |
size | 8,717 |
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"
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);
}