SimRng

Trait SimRng 

Source
pub trait SimRng:
    RngCore
    + SeedableRng
    + Debug {
    // Provided methods
    fn gen_bool(&mut self, p: f64) -> bool { ... }
    fn gen_bools(&mut self, p: f64, n: usize) -> Vec<bool> { ... }
    fn coin_flip(&mut self) -> bool { ... }
    fn choose_weighted<'a, T>(&mut self, choices: &'a Choices<T>) -> &'a T { ... }
    fn from_entropy() -> Self { ... }
}
Expand description

Represents the minimal interface needed for simulations. This trait also allows the blanket implementation provided by Rng to be overridden in favor of potentially more efficient implementations.

Provided Methods§

Source

fn gen_bool(&mut self, p: f64) -> bool

Generate a single bool where true has a probability of p.

Source

fn gen_bools(&mut self, p: f64, n: usize) -> Vec<bool>

Generates a vector of bools, where true has an independent probability of p.

Source

fn coin_flip(&mut self) -> bool

Gives true and false each with probability of 50%

Source

fn choose_weighted<'a, T>(&mut self, choices: &'a Choices<T>) -> &'a T

Choose between options given a weighted probabilities.

Source

fn from_entropy() -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§