Upgrading rand 0.8 to 0.9
Breaking0.8.8 → 0.9.5Breaking39Security7Platform5Deprecated2New59Changed37Fixed23Other71
BreakingUpgrade verdict
36 breaking changes and 5 platform requirement changes and 7 security fixes.
In plain terms
- Rename fn SeedableRng::from_rng -> try_from_rng and add infallible variant fn from_rng.
- Rename fn SeedableRng::from_entropy -> from_os_rng and add fallible variant fn try_from_os_rng.
- Rename fn rand::thread_rng() to rand::rng() and remove from the prelude.
- Remove fn rand::random() from the prelude.
Must act Top 5 of 50 that need code or config changes
Requires Rust 1.63 from 0.9.0-beta.0 (none stated before).
Adds rayon ^1.7.
Drops libc.
Installs 23 packages in all (was 18).
What you must change
Breaking36
Rename fn SeedableRng::from_rng -> try_from_rng and add infallible variant fn from_rng.
try_from_rngRename fn SeedableRng::from_entropy -> from_os_rng and add fallible variant fn try_from_os_rng.
from_os_rngRename fn rand::thread_rng() to rand::rng() and remove from the prelude.
rand::thread_rng()rand::rng()Remove fn rand::random() from the prelude.
rand::random()Rename fn Rng::gen to random to avoid conflict with the new gen keyword in Rust 2024.
Rng::genrandomgenRename fns Rng::gen_range to random_range, gen_bool to random_bool, gen_ratio to random_ratio.
Rng::gen_rangerandom_rangegen_boolrandom_boolgen_ratiorandom_ratioRemove first parameter (rng) of ReseedingRng::new.
rngReseedingRng::newRename module rand::distributions to rand::distr.
rand::distributionsrand::distrRename distribution Standard to StandardUniform.
StandardStandardUniformRename trait distr::DistString -> distr::SampleString.
distr::DistStringdistr::SampleStringRename distr::DistIter -> distr::Iter, distr::DistMap -> distr::Map.
distr::DistIterdistr::Iterdistr::DistMapdistr::MapRemove impl of Distribution<Option> for StandardUniform.
Distribution<Option<T>>StandardUniformRemove support for generating isize and usize values with StandardUniform, Uniform (except via UniformUsize) and Fill and usage as a WeightedAliasIndex weight.
isizeusizeStandardUniformUniformUniformUsizeFillRename enum WeightedError to weighted::Error, revising variants and mark as #[non_exhaustive].
WeightedErrorweighted::Error#[non_exhaustive]Remove unused fields.
Remove redundant bounds.
Rename WeightedError → WeightError; add IndexedRandom, IndexedMutRandom.
Remove automatic (delayed) reseed-on-fork.
Rename Rng::gen to Rng::random.
Rng::genRng::randomRename doc_cfg to docsrs and use doc_auto_cfg.
doc_cfgdocsrsdoc_auto_cfgRename serde1 feature to serde.
serde1serdeRename gen_iter → random_iter, misc.
Remove some unsafe, update to zerocopy 0.8.0.
Remove u64 support for Poisson.
Remove conditional compilation around using core.
Remove SmallRng::from_thread_rng.
Make ReseedingRng::reseed discard remaining data from the last block generated.
ReseedingRng::reseedChange fn SmallRng::seed_from_u64 implementation.
SmallRng::seed_from_u64Allow UniformFloat::new samples and UniformFloat::sample_single to yield high.
UniformFloat::newUniformFloat::sample_singlehighFix portability of distribution Slice.
SliceFix IndexdRandom::choose_multiple_weighted for very small seeds and optimize for large input length / low memory.
IndexdRandom::choose_multiple_weightedOptimize fn sample_floyd, affecting output of rand::seq::index::sample and rand::seq::SliceRandom::choose_multiple.
sample_floydrand::seq::index::samplerand::seq::SliceRandom::choose_multipleNew, faster algorithms for IteratorRandom::choose and choose_stable.
IteratorRandom::choosechoose_stableNew, faster algorithms for SliceRandom::shuffle and partial_shuffle.
SliceRandom::shufflepartial_shuffleOptimize distribution Uniform: use Canon's method (single sampling) / Lemire's method (distribution sampling) for faster sampling (breaks value stability; ).
UniformOptimize fn sample_single_inclusive for floats (+~20% perf).
sample_single_inclusiveSecurity7
Rand is unsound with a custom logger using
rand::rng()Revise "not a crypto library" policy again.
Remove zerocopy dependency from rand.
zerocopyrandPolicy: "rand is not a crypto library".
Remove fork-protection from ReseedingRng and ThreadRng.
ReseedingRngThreadRngThreadRng::reseedUse zerocopy to replace some unsafe code.
zerocopyunsafeGitHub Workflows security hardening.
Platform5
Bump the MSRV to 1.63.0; note that 1.60.0 may work for dependents when using --ignore-rust-version.
--ignore-rust-versionBump MSRV to 1.51.0.
Bump MSRV to 1.56 (Edition 2021).
Bump the MSRV to 1.61.0.
Bump the MSRV to 1.63.0.
Deprecations to plan for
Deprecated2
Deprecate feature log.
logDeprecate rand::rngs::mock module and StepRng generator.
rand::rngs::mockStepRng