prrng 0.2.0

psuedo-random number generation
Documentation
  • Coverage
  • 52.81%
    47 out of 89 items documented21 out of 36 items with examples
  • Size
  • Source code size: 66.94 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 31.67 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • wainggan/prrng
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • wainggan

prrng

collection of psuedo-random number generators.

this crate provides a few prng algorithms, easily composable with each other via the the [Random] trait.

use prrng::XorShift32;
use prrng::Random;

fn main() {
    let mut rng = XorShift32::new(1);

    assert_eq!(rng.get(), 270369u32);
    assert_eq!(rng.get(), 67634689u32);

    // iterator
    assert_eq!(rng.next(), Some(0.7912035671411848));
    assert_eq!(rng.next(), Some(0.5683147178403836));

    // utility functions
    assert_eq!(rng.random_range(8.0..16.0) as u32, 9);
    assert_eq!(rng.random_range(8.0..16.0) as u32, 11);

    assert_eq!(rng.random::<u64>(), 11412124528153499447);
    assert_eq!(rng.random::<(u8, bool)>(), (138, false));
}