Rand
Source: std/rand.mw.
Seeded from the operating system (getrandom or its equivalent).
Random numbers.
random_bytes/random_u64: cryptographically secure, straight from the OS.Rng: fast xoshiro256** generator for simulations, shuffles, tests.
struct Rng { s0: u64; s1: u64; s2: u64; s3: u64;}Functions
Section titled “Functions”random_bytes
Section titled “random_bytes”fn random_bytes(buf: *u8, len: i64) -> i64random_u64
Section titled “random_u64”fn random_u64() -> u64rotl64
Section titled “rotl64”fn rotl64(x: u64, k: i64) -> u64splitmix64
Section titled “splitmix64”fn splitmix64(state: *u64) -> u64rng_seeded
Section titled “rng_seeded”fn rng_seeded(seed: u64) -> Rngrng_new
Section titled “rng_new”fn rng_new() -> RngSeeded from the operating system.
rng_next
Section titled “rng_next”fn rng_next(r: *Rng) -> u64rng_below
Section titled “rng_below”fn rng_below(r: *Rng, n: u64) -> u64Uniform in [0, n) without modulo bias (rejection sampling). n must be positive.
rng_range
Section titled “rng_range”fn rng_range(r: *Rng, lo: i64, hi: i64) -> i64Uniform in [lo, hi] (inclusive).
rng_f64
Section titled “rng_f64”fn rng_f64(r: *Rng) -> f64Uniform in [0, 1).
rng_bool
Section titled “rng_bool”fn rng_bool(r: *Rng) -> bool