pub struct RandomNumberGenerator { /* private fields */ }

Implementations

Creates a new RNG from a randomly generated seed

Creates a new RNG from a specific seed

Returns a random value of whatever type you specify

Returns a random value in the specified range, of type specified at the call site. This is INCLUSIVE of the first parameter, and EXCLUSIVE of the second. So range(1,6) will give you numbers from 1 to 5.

Rolls dice, using the classic 3d6 type of format: n is the number of dice, die_type is the size of the dice.

Returns the RNG’s next unsigned-64 type

Rolls dice based on a DiceType struct, including application of the bonus

Rolls dice based on passing in a string, such as roll_str(“1d12”)

Returns a random index into a slice

pub fn random_slice_entry<T>(&mut self, slice: &'a [T]) -> Option<&'a T>

Returns a random entry in a slice (or none if empty)

Get underlying RNG implementation for use in traits / algorithms exposed by other crates (eg. rand itself)

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.