Struct fastrand::Rng [−][src]
pub struct Rng(_);
Expand description
A random number generator.
Implementations
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 digit in the given base
.
Digits are represented by char
s in ranges 0-9 and a-z.
Panics if the base is zero or greater than 36.
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 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.
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
Auto Trait Implementations
impl !RefUnwindSafe for Rng
impl UnwindSafe for Rng
Blanket Implementations
Mutably borrows from an owned value. Read more