Trait tiamat::Random[][src]

pub trait Random {
    fn random<G: RandomGen>(rng: &mut G) -> Self;
}

A type that can be (pseudo-)randomly generated using a RandomGen.

Required Methods

Randomly generates a value.

In general, the generates values will be uniformly distributed in some way. See the instance documentations for more details.

In most cases, you might want to use RandomGen's wrapper method gen instead of writing out Random::random or Type::random.

Example

use tiamat::Random;

let mut rng = get_rng();

for i in 1..6 {
    let result = if bool::random(&mut rng) {
        "heads"
    } else {
        "tails"
    };
    println!("Coin flip #{}: {}!", i, result);
}

Implementations on Foreign Types

impl Random for u32
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for u64
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for u128
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for u8
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for u16
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for i8
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for i16
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for i32
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for i64
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for i128
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for usize
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for isize
[src]

Generates values that are uniformly distributed among all possible values.

impl Random for f32
[src]

Generates uniformly distributed values in the closed interval [0.0, 1.0].

Here, uniformly distributed that the generated values are as if a random real number in [0.0, 1.0] was generated and then rounded to the nearest floating point number.

impl Random for f64
[src]

Generates uniformly distributed values in the closed interval [0.0, 1.0].

Here, uniformly distributed that the generated values are as if a random real number in [0.0, 1.0] was generated and then rounded to the nearest floating point number.

impl Random for bool
[src]

Returns true and false with equal probability.

impl<R: Random> Random for Option<R>
[src]

Returns Some(rng.gen()) and None with equal probability.

The Some and None variants have equal probability; if a Some is generated, then the value inside is generated with its Random instance.

impl Random for char
[src]

Returns a char uniformly distributed among legal values, i.e. among Unicode scalar values.

impl Random for ()
[src]

Returns ().

impl<A: Random> Random for (A,)
[src]

Returns a tuple where each value was generated according to its own implementation of Random.

impl<A: Random, B: Random> Random for (A, B)
[src]

Returns a tuple where each value was generated according to its own implementation of Random.

impl<A: Random, B: Random, C: Random> Random for (A, B, C)
[src]

Returns a tuple where each value was generated according to its own implementation of Random.

impl<A: Random, B: Random, C: Random, D: Random> Random for (A, B, C, D)
[src]

Returns a tuple where each value was generated according to its own implementation of Random.

impl<A: Random, B: Random, C: Random, D: Random, E: Random> Random for (A, B, C, D, E)
[src]

Returns a tuple where each value was generated according to its own implementation of Random.

impl<A: Random, B: Random, C: Random, D: Random, E: Random, F: Random> Random for (A, B, C, D, E, F)
[src]

Returns a tuple where each value was generated according to its own implementation of Random.

impl<A: Random, B: Random, C: Random, D: Random, E: Random, F: Random, G: Random> Random for (A, B, C, D, E, F, G)
[src]

Returns a tuple where each value was generated according to its own implementation of Random.

impl<A: Random, B: Random, C: Random, D: Random, E: Random, F: Random, G: Random, H: Random> Random for (A, B, C, D, E, F, G, H)
[src]

Returns a tuple where each value was generated according to its own implementation of Random.

Implementors