Expand description
A type that can be randomly generated using an Rng.
Built-in Implementations
This crate implements Rand for various primitive types. Assuming the
provided Rng is well-behaved, these implementations generate values with
the following ranges and distributions:
- Integers (
i32,u32,isize,usize, etc.): Uniformly distributed over all values of the type. char: Uniformly distributed over all Unicode scalar values, i.e. all code points in the range0...0x10_FFFF, except for the range0xD800...0xDFFF(the surrogate code points). This includes unassigned/reserved code points.bool: Generatesfalseortrue, each with probability 0.5.- Floating point types (
f32andf64): Uniformly distributed in the half-open range[0, 1). (TheOpen01,Closed01,Exp1, andStandardNormalwrapper types produce floating point numbers with alternative ranges or distributions.)
The following aggregate types also implement Rand as long as their
component types implement it:
- Tuples and arrays: Each element of the tuple or array is generated
independently, using its own
Randimplementation. Option<T>: ReturnsNonewith probability 0.5; otherwise generates a randomTand returnsSome(T).