Expand description
Utilities for random number generation.
This module re-exports the rand
crate, except for the random number generators.
User should call thread_rng()
to retrieve the deterministic random number
generator from the current madsim context. Do not use rand
crate directly,
because no determinism is guaranteed.
Example
use madsim::{runtime::Runtime, rand::{thread_rng, Rng}};
Runtime::new().block_on(async {
let mut rng = thread_rng();
rng.gen_bool(0.5);
rng.gen_range(0..10);
});
Re-exports
pub use rand::distributions;
pub use rand::seq;
pub use rand::CryptoRng;
pub use rand::Error;
pub use rand::Fill;
pub use rand::Rng;
pub use rand::RngCore;
pub use rand::SeedableRng;
Modules
Convenience re-export of common members
Structs
GlobalRng
madsim
Global deterministic random number generator.
Log
madsim
Random log for determinism check.
Functions
Generates a random value using the global random number generator.
Retrieve the deterministic random number generator from the current madsim context.