Skip to main content

Rng

Trait Rng 

Source
pub trait Rng {
    // Required method
    fn next_u64(&mut self) -> u64;

    // Provided methods
    fn next_u32(&mut self) -> u32 { ... }
    fn next_u8(&mut self) -> u8 { ... }
    fn chance(&mut self, numerator: u32, denominator: u32) -> bool { ... }
    fn index(&mut self, len: usize) -> usize { ... }
}
Expand description

A seeded random number generator for deterministic simulation.

All randomness in the simulation must flow through this trait. The same seed must produce the same sequence of values - this is what makes simulation runs reproducible and replayable.

Required Methods§

Source

fn next_u64(&mut self) -> u64

Provided Methods§

Source

fn next_u32(&mut self) -> u32

Returns a random u32.

Source

fn next_u8(&mut self) -> u8

Returns a random u8.

Source

fn chance(&mut self, numerator: u32, denominator: u32) -> bool

Source

fn index(&mut self, len: usize) -> usize

Returns a random usize in 0..len.

Implementors§