Crate randomize [] [src]

A dead simple to use randomization library for rust.

Functions exist to use a lazily-initialized, mutex-guarded, global generator. As you can guess, this is slower than necessary, so you can also make your own generator and call methods on that. The exact nature of the global generator is deliberately unspecified so that it can be improved or replaced in future versions if necessary.

This library gives priority to ease of use rather than trying to cover all possible uses. If you want a totally comprehensive randomization library for all possible cases then this really isn't for you.

NOT FOR CRYPTOGRAPHIC PURPOSES.

Structs

PCG32

A permuted congruential generator with 32-bits of output per step.

Traits

AnyRandom

A trait for types can can be generated in "any" state.

Functions

any

Gives a random value of the desired type from the global RNG.

any_ascii

Gives an ASCII value from the global RNG.

any_f32_zero_to_one

An f32 value from 0.0 to 1.0 (inclusive at both ends) from the global RNG.

in_range

Returns a value out of the Range specified using the global RNG.

next_u32

Returns a u32 from the global generator.

percent_chance

Returns true a percentage of the time (eg: 0.3 = 30%) from the global RNG.