Struct fastrand::Rng[][src]

pub struct Rng(_);
Expand description

A random number generator.

Implementations

Creates a new random number generator.

Creates a new random number generator with the initial seed.

Generates a random char in ranges a-z and A-Z.

Generates a random char in ranges a-z, A-Z and 0-9.

Generates a random bool.

Generates a random digit in the given base.

Digits are represented by chars in ranges 0-9 and a-z.

Panics if the base is zero or greater than 36.

Generates a random f32 in range 0..1.

Generates a random f64 in range 0..1.

Generates a random i8 in the given range.

Panics if the range is empty.

Generates a random i16 in the given range.

Panics if the range is empty.

Generates a random i32 in the given range.

Panics if the range is empty.

Generates a random i64 in the given range.

Panics if the range is empty.

Generates a random i128 in the given range.

Panics if the range is empty.

Generates a random isize in the given range.

Panics if the range is empty.

Generates a random char in range a-z.

Initializes this generator with the given seed.

Shuffles a slice randomly.

Generates a random u8 in the given range.

Panics if the range is empty.

Generates a random u16 in the given range.

Panics if the range is empty.

Generates a random u32 in the given range.

Panics if the range is empty.

Generates a random u64 in the given range.

Panics if the range is empty.

Generates a random u128 in the given range.

Panics if the range is empty.

Generates a random usize in the given range.

Panics if the range is empty.

Generates a random char in range A-Z.

Trait Implementations

Clones the generator by deterministically deriving a new generator based on the initial seed.

Example
// Seed two generators equally, and clone both of them.
let base1 = fastrand::Rng::new();
base1.seed(0x4d595df4d0f33173);
base1.bool(); // Use the generator once.

let base2 = fastrand::Rng::new();
base2.seed(0x4d595df4d0f33173);
base2.bool(); // Use the generator once.

let rng1 = base1.clone();
let rng2 = base2.clone();

assert_eq!(rng1.u64(..), rng2.u64(..), "the cloned generators are identical");

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.