Skip to main content

RandomSource

Trait RandomSource 

pub trait RandomSource: Sized {
    type Positional: PositionalRandom<Source = Self>;

Show 15 methods // Required methods fn set_seed(&mut self, seed: i64); fn next_int(&mut self) -> i32; fn next_int_bound(&mut self, bound: i32) -> Result<i32, InvalidBound>; fn next_long(&mut self) -> i64; fn next_boolean(&mut self) -> bool; fn next_float(&mut self) -> f32; fn next_double(&mut self) -> f64; fn next_gaussian(&mut self) -> f64; fn fork_positional(&mut self) -> Self::Positional; fn fork(&mut self) -> Self where Self: Sized; // Provided methods fn consume_count(&mut self, count: i32) { ... } fn next_int_between_inclusive( &mut self, min: i32, max: i32, ) -> Result<i32, InvalidBound> { ... } fn next_int_between( &mut self, origin: i32, bound: i32, ) -> Result<i32, InvalidBound> { ... } fn triangle(&mut self, mean: f64, deviation: f64) -> f64 { ... } fn triangle_float(&mut self, mean: f32, deviation: f32) -> f32 { ... }
}

Required Associated Types§

type Positional: PositionalRandom<Source = Self>

Required Methods§

fn set_seed(&mut self, seed: i64)

fn next_int(&mut self) -> i32

fn next_int_bound(&mut self, bound: i32) -> Result<i32, InvalidBound>

fn next_long(&mut self) -> i64

fn next_boolean(&mut self) -> bool

fn next_float(&mut self) -> f32

fn next_double(&mut self) -> f64

fn next_gaussian(&mut self) -> f64

MarsagliaPolarGaussian over this source; the cached second value is part of the source state (reset by set_seed where vanilla resets it).

fn fork_positional(&mut self) -> Self::Positional

fn fork(&mut self) -> Self
where Self: Sized,

Provided Methods§

fn consume_count(&mut self, count: i32)

fn next_int_between_inclusive( &mut self, min: i32, max: i32, ) -> Result<i32, InvalidBound>

fn next_int_between( &mut self, origin: i32, bound: i32, ) -> Result<i32, InvalidBound>

fn triangle(&mut self, mean: f64, deviation: f64) -> f64

fn triangle_float(&mut self, mean: f32, deviation: f32) -> f32

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

§

impl RandomSource for LegacyRandom

§

type Positional = LegacyPositionalRandom

§

impl RandomSource for XoroshiroRandom

§

type Positional = XoroshiroPositionalRandom

§

impl<R> RandomSource for WorldgenRandom<R>
where R: WorldgenSource,

§

type Positional = WorldgenPositional<<R as RandomSource>::Positional>