Trait rand::Rand
[−]
[src]
pub trait Rand {
fn rand<R>(rng: &mut R) -> Self
where
R: Rng;
}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).
Required Methods
fn rand<R>(rng: &mut R) -> Self where
R: Rng,
R: Rng,
Generates a random instance of this type using the specified source of randomness.
Implementations on Foreign Types
impl<A, B, C, D> Rand for (A, B, C, D) where
A: Rand,
B: Rand,
C: Rand,
D: Rand, [src]
A: Rand,
B: Rand,
C: Rand,
D: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl Rand for i8[src]
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl Rand for char[src]
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl Rand for usize[src]
impl<T> Rand for [T; 32 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<A> Rand for (A,) where
A: Rand, [src]
A: Rand,
impl<A, B, C, D, E, F, G, H, I, J> Rand for (A, B, C, D, E, F, G, H, I, J) where
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
H: Rand,
I: Rand,
J: Rand, [src]
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
H: Rand,
I: Rand,
J: Rand,
impl Rand for u32[src]
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for Option<T> where
T: Rand, [src]
T: Rand,
impl<A, B, C, D, E> Rand for (A, B, C, D, E) where
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand, [src]
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl Rand for i16[src]
impl Rand for u64[src]
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl Rand for i32[src]
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl Rand for isize[src]
impl<A, B, C, D, E, F, G> Rand for (A, B, C, D, E, F, G) where
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand, [src]
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<A, B, C, D, E, F, G, H> Rand for (A, B, C, D, E, F, G, H) where
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
H: Rand, [src]
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
H: Rand,
impl<T> Rand for [T; 32 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl Rand for f64[src]
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<A, B> Rand for (A, B) where
A: Rand,
B: Rand, [src]
A: Rand,
B: Rand,
impl<A, B, C, D, E, F, G, H, I, J, K, L> Rand for (A, B, C, D, E, F, G, H, I, J, K, L) where
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
H: Rand,
I: Rand,
J: Rand,
K: Rand,
L: Rand, [src]
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
H: Rand,
I: Rand,
J: Rand,
K: Rand,
L: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<A, B, C> Rand for (A, B, C) where
A: Rand,
B: Rand,
C: Rand, [src]
A: Rand,
B: Rand,
C: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1] where
T: Rand, [src]
T: Rand,
impl Rand for i64[src]
impl<A, B, C, D, E, F, G, H, I, J, K> Rand for (A, B, C, D, E, F, G, H, I, J, K) where
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
H: Rand,
I: Rand,
J: Rand,
K: Rand, [src]
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
H: Rand,
I: Rand,
J: Rand,
K: Rand,
impl<T> Rand for [T; 32] where
T: Rand, [src]
T: Rand,
impl Rand for f32[src]
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl Rand for ()[src]
impl Rand for u16[src]
impl Rand for bool[src]
impl<A, B, C, D, E, F, G, H, I> Rand for (A, B, C, D, E, F, G, H, I) where
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
H: Rand,
I: Rand, [src]
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
G: Rand,
H: Rand,
I: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1
- 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1][src]
impl Rand for u8[src]
impl<A, B, C, D, E, F> Rand for (A, B, C, D, E, F) where
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand, [src]
A: Rand,
B: Rand,
C: Rand,
D: Rand,
E: Rand,
F: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
impl<T> Rand for [T; 32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1] where
T: Rand, [src]
T: Rand,
Implementors
impl Rand for Open01<f32>impl Rand for Exp1impl Rand for Closed01<f64>impl Rand for XorShiftRngimpl Rand for StandardNormalimpl Rand for ChaChaRngimpl Rand for Open01<f64>impl Rand for Closed01<f32>impl Rand for Isaac64Rngimpl Rand for IsaacRng