Trait Rng

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

    // Provided methods
    fn random_range<T>(&mut self, range: Range<T>) -> T
       where T: RangeSample { ... }
    fn gen_bool(&mut self) -> bool { ... }
    fn normal(&mut self, mean: f64, sd: f64) -> f64 { ... }
}
Expand description

Trait implemented by random number generators.

Required Methods§

Source

fn next_u64(&mut self) -> u64

Generate the next random u64 value.

Provided Methods§

Source

fn random_range<T>(&mut self, range: Range<T>) -> T
where T: RangeSample,

Generate a value uniformly in the given range.

Source

fn gen_bool(&mut self) -> bool

Generate a boolean with probability 0.5 of being true.

Source

fn normal(&mut self, mean: f64, sd: f64) -> f64

Sample from a normal distribution using the Box-Muller transform.

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§