Crate randomize[−][src]
A dead simple to use randomization library for rust.
The library contains a trait for an RNG family, PCG
, and two main
implementations from that family: PCG32
and PCG64
.
use randomize::{PCG, PCG32}; #[cfg(feature = "std")] let time64 = randomize::u64_from_time(); #[cfg(not(feature = "std"))] let time64 = 100; let gen = &mut PCG32::new(time64, time64); println!("here's a u32 value: {}", gen.next_u32());
There are also a selection of functions that will automatically use a
global, lazily initialized, mutex guarded PCG32
value to get you your
results.
#[cfg(feature = "std")] use randomize::global; #[cfg(feature = "std")] { if global::any() { let x: u32 = global::any(); println!("x is a u32: {}", x); } else { let x: [char; 10] = global::any(); println!("x is a 10 character array: {:?}", x); println!("A random character is: {}", global::any_in_slice(&x).unwrap()); } }
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 you probably want the rand
crate.
NOT FOR CRYPTOGRAPHIC PURPOSES.
Re-exports
pub use generators::*; |
pub use distribution::*; |
pub use anyrandom::AnyRandom; |
Modules
anyrandom |
The module for the |
distribution |
The module for the |
generators |
The module for the various generators. |
global |
The module for all details relating to the implicit global generator. |
macros |
Holds the macros, since they're the only thing in rust where the order you declare them matters. |
Macros
make_compact_pcg32_type |
Makes a variant of the |
make_compact_pcg64_type |
Makes a variant of the |
Functions
u64_from_time |
Returns a |