Skip to content

Upgrading rand 0.7 to 0.8

Breaking0.7.3 → 0.8.8Breaking9Security1Platform1Deprecated2New12Changed9Fixed13Other12

BreakingUpgrade verdict

9 breaking changes and a platform requirement change and a security fix.

  • Removes the `wasm-bindgen` and `stdweb` feature flags; see the getrandom documentation for WASM support.
  • `ThreadRng` is no longer `Copy`, enabling safe usage within thread-local destructors.
  • `gen_range(a, b)` is replaced with `gen_range(a..b)`; `gen_range(a..=b)` is also supported, and `a` and `b` can no longer be references or SIMD types.
  • Drop the experimental simd_support feature.
Top 5 of 13 that need code or config changes

Adds bincode ^1.2.1, serde ^1.0.103, serde_json ^1.0.99.

Drops getrandom, log, packed_simd, rand_hc.

Installs 18 packages in all (was 20).

Breaking9
Removes the wasm-bindgen and stdweb feature flags; see the getrandom documentation for WASM support.
wasm-bindgenstdweb
ThreadRng is no longer Copy, enabling safe usage within thread-local destructors.
ThreadRng
gen_range(a, b) is replaced with gen_range(a..b); gen_range(a..=b) is also supported, and a and b can no longer be references or SIMD types.
gen_range
Drop the experimental simd_support feature.
simd_support
ReadRng::next_u32 and next_u64 now use little-Endian conversion instead of native-Endian, changing results on Big-Endian platforms.
ReadRng::next_u32ReadRng::next_u64
Replaces AsByteSliceMut with Fill and adds support for [bool], [char], [f32] and [f64].
AsByteSliceMutFill
Restricts rand::rngs::adapter to std.
rand::rngs::adapter
Implements IntoIterator for IndexVec, replacing the into_iter method.
IndexVecIntoIteratorinto_iter
Moves rand::distributions::alias_method::WeightedIndex to rand_distr::WeightedAliasIndex; the simpler rand::distribution::WeightedIndex remains.
rand::distributions::alias_method::WeightedIndexrand_distr::WeightedAliasIndexrand::distribution::WeightedIndex
Security1
Rand is unsound with a custom logger using rand::rng()
Platform1
The minimum supported Rust version is now 1.36.
Deprecated2
Deprecate feature log ().
log
Deprecate rngs::adapter::ReadRng.
rngs::adapter::ReadRng