[][src]Crate random_trait

Random Trait

This crate provides a simple thin trait for producing generic random values based on any random source. The crates assurances are based on the assurances of the RNG it is implemented on.
if that RNG is cryptographically secure then this crate should provide a cryptographically secure numbers. (including floats) if the RNG is biased (which is fine for tests and some other applications) then the results will also be bias. This crate does not try to compensate for biases in the RNG source.

please see the GenerateRand and Random for more information and examples.

Traits

GenerateRand

This trait is used by Random::gen() as a generic function to create a random value for any type which implements it. I try to give by default implementations for all the types in libcore, including arrays and tuples, if anything is missing please raise the issue. You can implement this for any of your types.

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).