Struct af_core::random::Rng[][src]

pub struct Rng { /* fields omitted */ }

A random number generator.

Implementations

impl Rng[src]

pub fn new() -> Rng[src]

Creates a new Rng with a random seed.

pub fn fill_bytes(&mut self, bytes: &mut [u8])[src]

Fills a slice with random bytes.

pub fn gen<T: Random>(&mut self) -> T[src]

Generates a random value.

pub fn gen_chance(&mut self, probability: f64) -> bool[src]

Returns true with a given probability.

The probability is the chance from 0.0 (never) to 1.0 (always) that this function returns true.

pub fn gen_range<T: SampleUniform>(&mut self, range: impl SampleRange<T>) -> T[src]

Generates a random number within a given range.

pub fn gen_ratio<T: Number + SampleUniform>(
    &mut self,
    numerator: T,
    denominator: T
) -> bool
[src]

Returns true with a probability expressed by the ratio between two given numbers.

pub fn shuffle<T>(&mut self, slice: &mut [T])[src]

Randomly shuffles a slice in place.

Trait Implementations

impl Clone for Rng[src]

impl Default for Rng[src]

Auto Trait Implementations

impl RefUnwindSafe for Rng

impl Send for Rng

impl Sync for Rng

impl Unpin for Rng

impl UnwindSafe for Rng

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,