Skip to main content

RandomSource

Trait RandomSource 

Source
pub trait RandomSource: RngCore {
    // Provided method
    fn reseed(&mut self, seed: u64) { ... }
}
Expand description

A pluggable source of randomness for a SimEnv.

The RngCore supertrait means env.rng().sample(dist) keeps working for every source. Implementations that are seed-based override reseed so that SimEnv::set_seed can restart their stream; sources that are not seed-based (e.g. a recorded-data feed) may keep the default, which panics — consistent with the crate’s “programming error ⇒ panic” policy.

Provided Methods§

Source

fn reseed(&mut self, seed: u64)

Re-seed the source deterministically, restarting its stream.

The default implementation panics. Override it for seed-based sources.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl RandomSource for StdRng

Source§

fn reseed(&mut self, seed: u64)

Implementors§