[][src]Struct rand::rngs::mock::StepRng

pub struct StepRng { /* fields omitted */ }
[]

A simple implementation of RngCore for testing purposes.

This generates an arithmetic sequence (i.e. adds a constant each step) over a u64 number, using wrapping arithmetic. If the increment is 0 the generator yields a constant.

use rand::Rng;
use rand::rngs::mock::StepRng;
 
let mut my_rng = StepRng::new(2, 1);
let sample: [u64; 3] = my_rng.gen();
assert_eq!(sample, [2, 3, 4]);

Methods

impl StepRng
[src]
[]

[]

Create a StepRng, yielding an arithmetic sequence starting with initial and incremented by increment each time.

Trait Implementations

impl Debug for StepRng
[src]
[+]

[]

Formats the value using the given formatter. Read more

impl Clone for StepRng
[src]
[+]

[]

Returns a copy of the value. Read more

[]

Performs copy-assignment from source. Read more

impl RngCore for StepRng
[src]
[+]

[]

Return the next random u32. Read more

[]

Return the next random u64. Read more

[]

Fill dest with random data. Read more

[]

Fill dest entirely with random data. Read more

Auto Trait Implementations

impl Send for StepRng

impl Sync for StepRng

Blanket Implementations

impl<R> Rng for R where
    R: RngCore + ?Sized
[src]
[+]

[]

Return a random value supporting the [Standard] distribution. Read more

[]

Generate a random value in the range [low, high), i.e. inclusive of low and exclusive of high. Read more

[]

Sample a new value, using the given distribution. Read more

Important traits for DistIter<'a, D, R, T>
[]

Create an iterator that generates values using the given distribution. Read more

[]

Fill dest entirely with random bytes (uniform value distribution), where dest is any type supporting [AsByteSliceMut], namely slices and arrays over primitive integer types (i8, i16, u32, etc.). Read more

[]

Fill dest entirely with random bytes (uniform value distribution), where dest is any type supporting [AsByteSliceMut], namely slices and arrays over primitive integer types (i8, i16, u32, etc.). Read more

[]

Return a bool with a probability p of being true. Read more

[]

Return a random element from values. Read more

[]

Return a mutable pointer to a random element from values. Read more

[]

Shuffle a mutable slice in place. Read more

Important traits for Generator<T, R>
[]

Deprecated since 0.5.0

: use Rng::sample_iter(&Standard) instead

Return an iterator that will yield an infinite number of randomly generated items. Read more

[]

Deprecated since 0.5.0

: use gen_bool instead

Return a bool with a 1 in n chance of true Read more

Important traits for AsciiGenerator<R>
[]

Deprecated since 0.5.0

: use sample_iter(&Alphanumeric) instead

Return an iterator of random characters from the set A-Z,a-z,0-9. Read more

impl<T> From for T
[src]
[+]

[]

Performs the conversion.

impl<T, U> Into for T where
    U: From<T>, 
[src]
[+]

[]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]
[+]

[]

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

[]

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

recently added

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

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]
[+]

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

The type returned in the event of a conversion error.

[]

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

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]
[+]

Important traits for &'a mut W
[]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]
[+]

Important traits for &'a mut W
[]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]
[+]

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

The type returned in the event of a conversion error.

[]

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

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]
[+]

[]

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

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more