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.
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 new
thread_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)OsRng
OsRng
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 Windowslog
no_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
)log
fuchsia-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 CryptGenRandom
Rng
trait method choose_mut
arc4rand
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::sample
Rand
for arrays with n <= 32Rng
to be ?Sized
, impl for &mut R
and Box<R>
where R: ?Sized + Rng
winapi
for Windows API thingsgetrandom
syscall number for aarch64-unknown-linux-gnulog
is a dev dependencyis_getrandom_available
Weighted
old_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::rand
std::rand
gen_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_option
OSRng
in cryptographic context, and explain why we use /dev/urandom
instead of /dev/random
Rng::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_mut
fill()
instead of read()
rand
out of the standard library