[][src]Crate random_fast_rng

Random-fast-rng

This crate provides a fast non cryptographic random number generator that implements the Random trait.
Currently it's implemented using the Pcg32 algorithm, that generates 32 bit of random data for every state change.
the exact algorithm might change in the future, but the properties should stay the same (Blazing fast, non cryptographic, and minimal I/O) The crate is part of the random-rs facade, and as such supports older rust compilers(currently 1.13+) and should have only thin amount of dependencies.

This Random generator is good for testing uses, and use cases that require some non-determinism. it shouldn't be used to generate keys/passwords.

By enabling the std feature this crate exposes a new() function that uses SystemTime::now() to seed the RNG.
It also exposes a local_rng() function to give a persistent Rng that is seeded only once and is unique per thread (so there's no need to worry about dropping and reinitializing the Rng)

Re-exports

pub extern crate random_trait;

Structs

FastRng

A FastRng struct implementing Random. you can initialize it with your own seed using FastRng::seed() Or if the std feature is enabled call FastRng::new() which will seed it with the system time.
For ergonomics and ease of usability the Rng is also provided as a global thread local variable using FastRng::local_rng()

ThreadFastRng

A shim that points to the global FastRng instance. isn't safe for multi-threading.

Traits

Random

This is the base trait of the crate. By implementing the required method on your random generator source it will give you a long list of functions, the important of them is Random::gen() -> T which will produce a random value for every type which implements GenerateRand (you can implement this for your own types).

Functions

local_rng

Returns a thread local instance which is seeded only once per thread (no need to worry about dropping and reinitializing)