All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
A separate changelog is kept for rand_core.
You may also find the Upgrade Guide useful.
no_std (#1173)libc::pthread_atfork return value with panic on error (#1178)ReseedingRng is used from a fork handler (#1178)slice_partition_at_index feature (#1215)simd_support: update packed_simd (#1216)StdRng: Switch from HC128 to ChaCha12 on emscripten (#1142). We now use ChaCha12 on all platforms.Clone and Copy for Alphanumeric (#1126)Distribution::map to derive a distribution using a closure (#1129)Slice distribution (#1107)DistString trait with impls for Standard and Alphanumeric (#1133)Uniform float distributions for easier debugging of non-finite arguments (#1094, #1108)Uniform float distributions (#1108)rngs::adapter::ReadRng (#1130)no-std + alloc build by gating choose_multiple_weighted on std (#1088)UniformInt::sample_single_inclusive and Rng::gen_range when providing a full integer range (eg 0..=MAX) (#1087)getrandom updated to v0.2 (#1041)wasm-bindgen and stdweb feature flags. For details of WASM support, see the getrandom documentation. (#948)ReadRng::next_u32 and next_u64 now use little-Endian conversion instead of native-Endian, affecting results on Big-Endian platforms (#1061)nightly feature no longer implies the simd_support feature (#1048)simd_support feature to work on current nightlies (#1056)ThreadRng is no longer Copy to enable safe usage within thread-local destructors (#1035)gen_range(a, b) was replaced with gen_range(a..b). gen_range(a..=b) is also supported. Note that a and b can no longer be references or SIMD types. (#744, #1003)AsByteSliceMut with Fill and add support for [bool], [char], [f32], [f64] (#940)rand::rngs::adapter to std (#1027; see also #928)StdRng: add new std_rng feature flag (enabled by default, but might need to be used if disabling default crate features) (#948)StdRng: Switch from ChaCha20 to ChaCha12 for better performance (#1028)SmallRng: Replace PCG algorithm with xoshiro{128,256}++ (#1038)IteratorRandom::choose_stable as an alternative to choose which does not depend on size hints (#1057)IteratorRandom::choose (#1059)IntoIterator for IndexVec, replacing the into_iter method (#1007)seq module (#933)PartialEq and Eq for StdRng, SmallRng and StepRng (#979)serde1 feature and added Serialize/Deserialize to UniformInt and WeightedIndex (#974)Alphanumeric samples bytes instead of chars (#935)Uniform now supports char, enabling rng.gen_range('A'..='Z') (#1068)UniformSampler::sample_single_inclusive (#1003)rand::distributions::alias_method::WeightedIndex was moved to rand_distr::WeightedAliasIndex. The simpler alternative rand::distribution::WeightedIndex remains. (#945)WeightedIndex::update_weights (#956)WeightedIndex: return error on NaN instead of panic (#1005)random (#994)SmallRng may not be the best choice for performance and in some other cases (#1038)doc(cfg) to annotate feature-gated items (#1019)Bernoulli distribution constructors now reports an error on NaN and on denominator == 0. (#925)std::sync::Once to register fork handler, avoiding possible atomicity violation (#928)std::error::Error for BernoulliError (#919)rand_core 0.5.1 (#890)This release was yanked since it depends on rand_core::OsRng added in 0.5.1 but specifies a dependency on version 0.5.0 (#890), causing a broken builds when updating from rand 0.7.0 without also updating rand_core.
no_std behaviour, appropriately enable c2-chacha's std feature (#844)alloc feature in no_std is available since Rust 1.36 (#856)no_std target to CI to continuously evaluate no_std status (#844)WeightedIndex: allow adjusting a sub-set of weights (#866)Uniform for 8- and 16-bit ints (#809)rand_xorshift, rand_isaac, rand_jitter crates (#759, #765)winapi (#724)build.rs files (#824)rand_core 0.5.0Error type redesigned with new API (#800)from_entropy method to SeedableRng and remove FromEntropy (#800)SeedableRng::from_rng is now expected to be value-stable (#815)rand_os to new getrandom crate (#765, getrandom)StdRng and ThreadRng (#792)SmallRng (#792)ThreadRng now supports Copy (#758)EntropyRng (#765)std (#724)rand_distr (#761)Bernoulli::new constructor now returns a Result (#803)Distribution::sample_iter adjusted for more flexibility (#758)distributions::weighted::alias_method::WeightedIndex for O(1) sampling (#692)NonZeroU* types with the Standard distribution (#728)Binomial distribution sampling (#735, #740, #752)u32 samples for usize where possible (#809)rand_core to 0.4 (#703)JitterRng to its own crate (#685)wasm32-unknown-unknown compile but fail at run-time if missing bindingsg (#686)std feature require the optional rand_os dependency (#675)rand_os from rand to avoid breakage (#674)Default for ThreadRng (#657)rngs::OsRng to rand_os sub-crate; clean up code; use as dependency (#643) ##BLOCKER##rand_xoshiro sub-crate, plus benchmarks (#642, #668)UniformInt::sample_single (#662)autocfg instead of rustc_version for rustc version detection (#664)i128 and u128 if the target_os is emscripten (#671: work-around Emscripten limitation)UnitCircle and UnitSphereSurface distributions (no PR)Duration also for no_std (only since Rust 1.25) (#649)libc (#647)OsRng for powerpc64, sparc and sparc64 (#609)syscall from libc on Linux instead of redefining it (#629)SmallRng to use PCG (#623)Pcg32 and Pcg64Mcg generators (#632)Rc from ThreadRng (#615)Rng.gen_ratio() and Bernoulli::new_ratio() (#491)Uniform strictly respect f32 / f64 high/low bounds (#477)gen_range and Uniform to work on non-Copy types (#506)Uniform supports inclusive ranges: Uniform::from(a..=b). This is automatically enabled for Rust >= 1.27. (#566)TrustedLen and FusedIterator for DistIter (#620)Dirichlet distribution (#485)Bernoulli::new (#500)char sampling (#519)std::time::Duration (#583)seq module (#483, #515)WeightedIndex and choose_weighted (#518, #547)sample_indices function. (#479)Iterator::size_hint() to speed up IteratorRandom::choose (#593)i128 and u128 is automatically enabled for Rust >= 1.26. This renders the i128_support feature obsolete. It still exists for backwards compatibility but does not have any effect. This breaks programs using Rand with i128_support on nightlies older than Rust 1.26. (#571)OsRng work via WASM/stdweb for WebWorkersOsRng and JitterRng on unsupported platforms (#512; fixes #503).OsRng/dev/random. (#484)getentropy like OpenBSD. (#484)getrandom if available, otherwise /dev/random. (#484)stdweb: split the read up in chunks. (#484)/dev/random. (#484)fill_bytes. (#484)rand_core crate. (#288)rand_derive. (#256)prelude (and module reorganisation). (#435)log feature. Logging is now available in JitterRng, OsRng, EntropyRng and ReseedingRng. (#246)serde1 feature for some PRNGs. (#189)stdweb feature for OsRng support on WASM via stdweb. (#272, #336)Rng traitRng in RngCore and Rng extension trait. next_u32, next_u64 and fill_bytes are now part of RngCore. (#265)Rng::sample. (#256)Rng::gen_weighted_bool. (#308)Rng::gen_bool. (#308)Rng::next_f32 and Rng::next_f64. (#273)Rng::fill and Rng::try_fill methods. (#247)Rng::gen_iter. (#286)Rng::gen_ascii_chars. (#279)rand_core craterand now depends on new rand_core crate (#288)RngCore and SeedableRng are now part of rand_core. (#288)impl and le. (#209, #228)Error and ErrorKind. (#225)CryptoRng marker trait. (#273)BlockRngCore trait. (#281)BlockRng and BlockRng64 wrappers to help implementations. (#281, #325)SeedableRng trait. (#233)RngCore::next_u64 and RngCore::fill_bytes. (#288)RngCore::try_fill_bytes. (#225)FromEntropy trait. (#233, #375)SmallRng wrapper. (#296)ReseedingRng to only work with BlockRngCore (substantial performance improvement). (#281)weak_rng. Use SmallRng instead. (#296)AsciiGenerator. (#279)StdRng and thread_rng to HC-128. (#277)StdRng must now be created with from_entropy instead of newthread_rng reseeding threshold to 32 MiB. (#277)Copy. (#209)Debug implementations no longer show internals. (#209)Clone for ReseedingRng, JitterRng, OsRng`. (#383, #384)XorShiftRng, IsaacRng and Isaac64Rng under the serde1 feature. (#189)BlockRngCore for ChaChaCore and Hc128Core. (#281)Isaac64Rng::next_u32 no longer throws away half the results. (#209)IsaacRng::new_from_u64 and Isaac64Rng::new_from_u64. (#209)Hc128Rng. (#210)JitterRng to get its size down from 2112 to 24 bytes. (#251)OsRngOsRng via stdweb, behind the stdweb feature. (#272, #336)getrandom on more platforms for Linux, and on Android. (#338)SecRandomCopyBytes interface on macOS. (#322)OsRng. (#239)/dev/random, then /dev/urandom. (#338)OsRng (using new error type). (#225)OsRng now uses non-blocking when available. (#225)EntropyRng, which provides OsRng, but has JitterRng as a fallback. (#235)Distribution trait. (#256)Distribution::sample_iter and Rng::::sample_iter. (#361)Rand, Sample and IndependentSample traits. (#256)Standard distribution (replaces most Rand implementations). (#256)Binomial and Poisson distributions. (#96)Bernoulli dsitribution. (#411)Alphanumeric distribution. (#279)Closed01 distribution, add OpenClosed01. (#274, #420)Range type, making it possible to implement it for user types. (#274)Range to Uniform. (#395)Uniform::new_inclusive for inclusive ranges. (#274)Standard distribution for char uses Uniform internally. (#274)Standard distribution for bool uses sign test. (#274)Standard distribution for Wrapping<T>. (#436)Uniform distribution for Duration. (#427)winapi on Windowslogno_std supportJitterRng added as a high-quality alternative entropy source using the system timerseq module with sample_iter, sample_slice, etc.thread_rng uses JitterRng if seeding from system time fails (slower but more secure than previous method)sample function deprecated (replaced by sample_iter)logfuchsia-zircon dependency to 0.3.2log <= 0.3.8 for dev buildsfuchsia-zircon dependency to 0.3thread_rng is seeded from the system time if OsRng failsweak_rng now uses thread_rng internallyRand for (i|u)i128RtlGenRandom instead of CryptGenRandomRng trait method choose_mutarc4rand for OsRng on FreeBSD.arc4random(3) for OsRng on OpenBSD.OsRng::fill_bytes on Windowsnext_f32 and next_f64 with the technique described Saito & Matsumoto at MCQMC'08. The new method should exhibit a slightly more uniform distribution.rand::sampleRand for arrays with n <= 32Rng to be ?Sized, impl for &mut R and Box<R> where R: ?Sized + Rngwinapi for Windows API thingsgetrandom syscall number for aarch64-unknown-linux-gnulog is a dev dependencyis_getrandom_availableWeightedold_io to std::io)std::rand, including:StdRng, SeedableRng, TreadRng, weak_rng()ReaderRng: A wrapper around any Reader to treat it as an RNG.std::randstd::randgen_weighted_bool(1)next_f64 and next_f32 to RngTaskRng to ThreadRng and task_rng to thread_rng (since a runtime is removed from Rust).choose_optionOSRng in cryptographic context, and explain why we use /dev/urandom instead of /dev/randomRng::gen_iter() which will return an infinite stream of random valuesRng::gen_ascii_chars() which will return an infinite stream of random ascii charactersRng.choose(), rename Rng.choose_option() to .choose()Vec<Weighted<T>>, but rather a &mut [Weighted<T>]. This means that the WeightedChoice structure now has a lifetime associated with it.sample method on Rng has been moved to a top-level function in the rand module due to its dependence on Vec.Rng::gen_vec() was removed. Previous behavior can be regained with rng.gen_iter().take(n).collect()Rng::gen_ascii_str() was removed. Previous behavior can be regained with rng.gen_ascii_chars().take(n).collect()Rand trait so they can be generated with a random seed from another random number generator. This allows the stdlib to use an OSRng to create seeded instances of these RNGs.Box<T> and @T were removed. These seemed to be pretty rare in the codebase, and it allows for librand to not depend on liballoc. Additionally, other pointer types like Rc and Arc were not supported.Rng.shuffle's functionality with .shuffle_mutfill() instead of read()rand out of the standard library