From rand 0.10
| rand 0.10 | vrd |
|---|---|
let mut rng = rand::rng(); | let mut rng = Random::new(); |
rng.random::<u32>() | rng.rand() |
rng.random_range(0..n) | rng.uint(0, n - 1) |
rng.fill_bytes(&mut buf) | rng.try_fill_bytes(&mut buf).unwrap() |
slice.choose(&mut rng) | rng.choose(slice) |
slice.shuffle(&mut rng) | rng.shuffle(slice) |
StdRng::seed_from_u64(s) | Random::from_u64_seed(s) |
ChaCha20Rng::from_seed(s) | Random::from_secure_seed(s) (crypto) |
ChaCha20Rng::from_os_rng() | Random::new_secure() (crypto) |
You do not have to change every call at once: Random implements rand's TryRng and SeedableRng, so it can be passed to code that takes those traits. try_fill_bytes needs rand's TryRng trait in scope. uint takes an inclusive upper bound, hence n - 1.
From an older vrd
The site you may have read before described vrd 0.0.6, built around the Mersenne Twister. Versions 0.0.10 and 0.0.11 changed that:
Random::new()is Xoshiro256++, not the Mersenne Twister. UseRandom::new_mersenne_twister()to keep MT19937.int,uintandrandom_rangeare unbiased, so they return different values for the same seed than before 0.0.10.normal()uses the Ziggurat method since 0.0.11, which also changes its output for a seed.- The generic
fill()method is gone: usetry_fill_bytesfrom rand'sTryRng, or build values fromrand()andu64(). - The
loggingfeature and the serde_json, YAML and TOML helpers are gone; useserdedirectly with theserdefeature. Randomno longer derivesEq,Hash,OrdorPartialOrd.
The CHANGELOG lists every change, release by release.