Trait rand::NewRng [] [src]

pub trait NewRng: SeedableRng {
    fn new() -> Result<Self, Error>;
}

A convenient way to seed new algorithmic generators, otherwise known as pseudo-random number generators (PRNGs).

This is the recommended way to create PRNGs, unless a deterministic seed is desired (in which case SeedableRng::from_seed should be used).

Note: this trait is automatically implemented for any PRNG implementing SeedableRng and is not intended to be implemented by users.

Example

use rand::{StdRng, SampleRng, NewRng};

let mut rng = StdRng::new().unwrap();
println!("Random die roll: {}", rng.gen_range(1, 7));

Required Methods

Creates a new instance, automatically seeded with fresh entropy.

Normally this will use OsRng, but if that fails JitterRng will be used instead. Both should be suitable for cryptography. It is possible that both entropy sources will fail though unlikely.

Implementors