pub struct Standard;
Expand description

A generic random value distribution, implemented for many primitive types. Usually generates values with a numerically uniform distribution, and with a range appropriate to the type.

§Provided implementations

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 range 0...0x10_FFFF, except for the range 0xD800...0xDFFF (the surrogate code points). This includes unassigned/reserved code points.
  • bool: Generates false or true, each with probability 0.5.
  • Floating point types (f32 and f64): Uniformly distributed in the half-open range [0, 1). See notes below.
  • Wrapping integers (Wrapping<T>), besides the type identical to their normal integer variants.
  • Non-zero integers (NonZeroU8), which are like their normal integer variants but cannot produce zero.
  • SIMD types like x86’s __m128i, std::simd’s u32x4/f32x4/ mask32x4 (requires simd_support), where each lane is distributed like their scalar Standard variants. See the list of Standard implementations for more.

The Standard distribution also supports generation of the following compound types where all component types are supported:

  • Tuples (up to 12 elements): each element is generated sequentially.
  • Arrays: each element is generated sequentially; see also Rng::fill which supports arbitrary array length for integer and float types and tends to be faster for u32 and smaller types. Note that Rng::fill and Standard’s array support are not equivalent: the former is optimised for integer types (using fewer RNG calls for element types smaller than the RNG word size), while the latter supports any element type supported by Standard.
  • Option<T> first generates a bool, and if true generates and returns Some(value) where value: T, otherwise returning None.

§Custom implementations

The Standard distribution may be implemented for user types as follows:

use rand::Rng;
use rand::distributions::{Distribution, Standard};

struct MyF32 {
    x: f32,
}

impl Distribution<MyF32> for Standard {
    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> MyF32 {
        MyF32 { x: rng.gen() }
    }
}

§Example usage

use rand::prelude::*;
use rand::distributions::Standard;

let val: f32 = StdRng::from_entropy().sample(Standard);
println!("f32 from [0, 1): {}", val);

§Floating point implementation

The floating point implementations for Standard generate a random value in the half-open interval [0, 1), i.e. including 0 but not 1.

All values that can be generated are of the form n * ε/2. For f32 the 24 most significant random bits of a u32 are used and for f64 the 53 most significant bits of a u64 are used. The conversion uses the multiplicative method: (rng.gen::<$uty>() >> N) as $ty * (ε/2).

See also: Open01 which samples from (0, 1), OpenClosed01 which samples from (0, 1] and Rng::gen_range(0..1) which also samples from [0, 1). Note that Open01 uses transmute-based methods which yield 1 bit less precision but may perform faster on some architectures (on modern Intel CPUs all methods have approximately equal performance).

Trait Implementations§

source§

impl Clone for Standard

source§

fn clone(&self) -> Standard

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Standard

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Standard

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl DistString for Standard

Available on crate feature alloc only.

Note: the String is potentially left with excess capacity; optionally the user may call string.shrink_to_fit() afterwards.

source§

fn append_string<R: Rng + ?Sized>( &self, rng: &mut R, s: &mut String, len: usize )

Append len random chars to string
source§

fn sample_string<R: Rng + ?Sized>(&self, rng: &mut R, len: usize) -> String

Generate a String of len random chars
source§

impl<T, const N: usize> Distribution<[T; N]> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, _rng: &mut R) -> [T; N]

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<()> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A> Distribution<(A,)> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> (A,)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B> Distribution<(A, B)> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> (A, B)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B, C> Distribution<(A, B, C)> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> (A, B, C)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B, C, D> Distribution<(A, B, C, D)> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> (A, B, C, D)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B, C, D, E> Distribution<(A, B, C, D, E)> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> (A, B, C, D, E)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B, C, D, E, F> Distribution<(A, B, C, D, E, F)> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> (A, B, C, D, E, F)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B, C, D, E, F, G> Distribution<(A, B, C, D, E, F, G)> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> (A, B, C, D, E, F, G)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B, C, D, E, F, G, H> Distribution<(A, B, C, D, E, F, G, H)> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> (A, B, C, D, E, F, G, H)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B, C, D, E, F, G, H, I> Distribution<(A, B, C, D, E, F, G, H, I)> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> (A, B, C, D, E, F, G, H, I)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B, C, D, E, F, G, H, I, J> Distribution<(A, B, C, D, E, F, G, H, I, J)> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> (A, B, C, D, E, F, G, H, I, J)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B, C, D, E, F, G, H, I, J, K> Distribution<(A, B, C, D, E, F, G, H, I, J, K)> for Standard

source§

fn sample<R: Rng + ?Sized>( &self, rng: &mut R ) -> (A, B, C, D, E, F, G, H, I, J, K)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<A, B, C, D, E, F, G, H, I, J, K, L> Distribution<(A, B, C, D, E, F, G, H, I, J, K, L)> for Standard

source§

fn sample<R: Rng + ?Sized>( &self, rng: &mut R ) -> (A, B, C, D, E, F, G, H, I, J, K, L)

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<i128>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroI128

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<i16>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroI16

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<i32>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroI32

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<i64>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroI64

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<i8>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroI8

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<isize>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroIsize

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<u128>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroU128

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<u16>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroU16

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<u32>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroU32

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<u64>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroU64

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<u8>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroU8

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<NonZero<usize>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> NonZeroUsize

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<T> Distribution<Option<T>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Option<T>

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<T> Distribution<Wrapping<T>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Wrapping<T>

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<__m128i> for Standard

Available on x86 or x86-64 only.
source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> __m128i

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<__m256i> for Standard

Available on x86 or x86-64 only.
source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> __m256i

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<bool> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> bool

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<char> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> char

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<f32> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f32

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<f64> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<i128> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> i128

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<i16> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> i16

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<i32> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> i32

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<i64> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> i64

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<i8> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> i8

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<isize> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> isize

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<u128> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u128

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<u16> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u16

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<u32> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u32

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<u64> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u64

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<u8> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u8

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Distribution<usize> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> usize

Generate a random value of T, using rng as the source of randomness.
source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl Serialize for Standard

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Standard

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,