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§
Sourcefn gen_bool(&mut self, p: f64) -> bool
fn gen_bool(&mut self, p: f64) -> bool
Generate a single bool where true has a probability of p.
Sourcefn gen_bools(&mut self, p: f64, n: usize) -> Vec<bool>
fn gen_bools(&mut self, p: f64, n: usize) -> Vec<bool>
Generates a vector of bools, where true has an independent probability of p.
Sourcefn choose_weighted<'a, T>(&mut self, choices: &'a Choices<T>) -> &'a T
fn choose_weighted<'a, T>(&mut self, choices: &'a Choices<T>) -> &'a T
Choose between options given a weighted probabilities.
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.