2 All notable changes to this project will be documented in this file.
4 The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md).
9 You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful.
11 ## [0.7.3] - 2020-01-10
13 - The `Bernoulli` distribution constructors now reports an error on NaN and on
14 `denominator == 0`. (#925)
15 - Use `std::sync::Once` to register fork handler, avoiding possible atomicity violation (#928)
16 - Fix documentation on the precision of generated floating-point values
19 - Unix: make libc dependency optional; only use fork protection with std feature (#928)
22 - Implement `std::error::Error` for `BernoulliError` (#919)
24 ## [0.7.2] - 2019-09-16
26 - Fix dependency on `rand_core` 0.5.1 (#890)
29 - Unit tests for value stability of distributions added (#888)
31 ## [0.7.1] - 2019-09-13
33 This release was yanked since it depends on `rand_core::OsRng` added in 0.5.1
34 but specifies a dependency on version 0.5.0 (#890), causing a broken builds
35 when updating from `rand 0.7.0` without also updating `rand_core`.
38 - Fix `no_std` behaviour, appropriately enable c2-chacha's `std` feature (#844)
39 - `alloc` feature in `no_std` is available since Rust 1.36 (#856)
40 - Fix or squelch issues from Clippy lints (#840)
43 - Add a `no_std` target to CI to continously evaluate `no_std` status (#844)
44 - `WeightedIndex`: allow adjusting a sub-set of weights (#866)
46 ## [0.7.0] - 2019-06-28
49 - Fix incorrect pointer usages revealed by Miri testing (#780, #781)
50 - Fix (tiny!) bias in `Uniform` for 8- and 16-bit ints (#809)
53 - Bumped MSRV (min supported Rust version) to 1.32.0
54 - Updated to Rust Edition 2018 (#823, #824)
55 - Removed dependence on `rand_xorshift`, `rand_isaac`, `rand_jitter` crates (#759, #765)
56 - Remove dependency on `winapi` (#724)
57 - Removed all `build.rs` files (#824)
58 - Removed code already deprecated in version 0.6 (#757)
59 - Removed the serde1 feature (It's still available for backwards compatibility, but it does not do anything. #830)
60 - Many documentation changes
63 - Updated to `rand_core` 0.5.0
64 - `Error` type redesigned with new API (#800)
65 - Move `from_entropy` method to `SeedableRng` and remove `FromEntropy` (#800)
66 - `SeedableRng::from_rng` is now expected to be value-stable (#815)
69 - OS interface moved from `rand_os` to new `getrandom` crate (#765, [getrandom](https://github.com/rust-random/getrandom))
70 - Use ChaCha for `StdRng` and `ThreadRng` (#792)
71 - Feature-gate `SmallRng` (#792)
72 - `ThreadRng` now supports `Copy` (#758)
73 - Deprecated `EntropyRng` (#765)
74 - Enable fork protection of ReseedingRng without `std` (#724)
77 - Many distributions have been moved to `rand_distr` (#761)
78 - `Bernoulli::new` constructor now returns a `Result` (#803)
79 - `Distribution::sample_iter` adjusted for more flexibility (#758)
80 - Added `distributions::weighted::alias_method::WeightedIndex` for `O(1)` sampling (#692)
81 - Support sampling `NonZeroU*` types with the `Standard` distribution (#728)
82 - Optimised `Binomial` distribution sampling (#735, #740, #752)
83 - Optimised SIMD float sampling (#739)
86 - Make results portable across 32- and 64-bit by using `u32` samples for `usize` where possible (#809)
88 ## [0.6.5] - 2019-01-28
90 - Update `rand_core` to 0.4 (#703)
91 - Move `JitterRng` to its own crate (#685)
92 - Add a wasm-bindgen test crate (#696)
95 - Fuchsia: Replaced fuchsia-zircon with fuchsia-cprng
98 - Use RFC 1946 for doc links (#691)
99 - Fix some doc links and notes (#711)
101 ## [0.6.4] - 2019-01-08
103 - Move wasm-bindgen shims to correct crate (#686)
104 - Make `wasm32-unknown-unknown` compile but fail at run-time if missing bindingsg (#686)
106 ## [0.6.3] - 2019-01-04
108 - Make the `std` feature require the optional `rand_os` dependency (#675)
109 - Re-export the optional WASM dependencies of `rand_os` from `rand` to avoid breakage (#674)
111 ## [0.6.2] - 2019-01-04
113 - Add `Default` for `ThreadRng` (#657)
114 - Move `rngs::OsRng` to `rand_os` sub-crate; clean up code; use as dependency (#643) ##BLOCKER##
115 - Add `rand_xoshiro` sub-crate, plus benchmarks (#642, #668)
118 - Fix bias in `UniformInt::sample_single` (#662)
119 - Use `autocfg` instead of `rustc_version` for rustc version detection (#664)
120 - Disable `i128` and `u128` if the `target_os` is `emscripten` (#671: work-around Emscripten limitation)
121 - CI fixes (#660, #671)
124 - Optimise memory usage of `UnitCircle` and `UnitSphereSurface` distributions (no PR)
126 ## [0.6.1] - 2018-11-22
127 - Support sampling `Duration` also for `no_std` (only since Rust 1.25) (#649)
128 - Disable default features of `libc` (#647)
130 ## [0.6.0] - 2018-11-14
132 ### Project organisation
133 - Rand has moved from [rust-lang-nursery](https://github.com/rust-lang-nursery/rand)
134 to [rust-random](https://github.com/rust-random/rand)! (#578)
135 - Created [The Rust Random Book](https://rust-random.github.io/book/)
136 ([source](https://github.com/rust-random/book))
137 - Update copyright and licence notices (#591, #611)
138 - Migrate policy documentation from the wiki (#544)
141 - Add fork protection on Unix (#466)
142 - Added support for wasm-bindgen. (#541, #559, #562, #600)
143 - Enable `OsRng` for powerpc64, sparc and sparc64 (#609)
144 - Use `syscall` from `libc` on Linux instead of redefining it (#629)
147 - Switch `SmallRng` to use PCG (#623)
148 - Implement `Pcg32` and `Pcg64Mcg` generators (#632)
149 - Move ISAAC RNGs to a dedicated crate (#551)
150 - Move Xorshift RNG to its own crate (#557)
151 - Move ChaCha and HC128 RNGs to dedicated crates (#607, #636)
152 - Remove usage of `Rc` from `ThreadRng` (#615)
154 ### Sampling and distributions
155 - Implement `Rng.gen_ratio()` and `Bernoulli::new_ratio()` (#491)
156 - Make `Uniform` strictly respect `f32` / `f64` high/low bounds (#477)
157 - Allow `gen_range` and `Uniform` to work on non-`Copy` types (#506)
158 - `Uniform` supports inclusive ranges: `Uniform::from(a..=b)`. This is
159 automatically enabled for Rust >= 1.27. (#566)
160 - Implement `TrustedLen` and `FusedIterator` for `DistIter` (#620)
162 #### New distributions
163 - Add the `Dirichlet` distribution (#485)
164 - Added sampling from the unit sphere and circle. (#567)
165 - Implement the triangular distribution (#575)
166 - Implement the Weibull distribution (#576)
167 - Implement the Beta distribution (#574)
171 - Optimise `Bernoulli::new` (#500)
172 - Optimise `char` sampling (#519)
173 - Optimise sampling of `std::time::Duration` (#583)
176 - Redesign the `seq` module (#483, #515)
177 - Add `WeightedIndex` and `choose_weighted` (#518, #547)
178 - Optimised and changed return type of the `sample_indices` function. (#479)
179 - Use `Iterator::size_hint()` to speed up `IteratorRandom::choose` (#593)
182 - Support for generating SIMD types (#523, #542, #561, #630)
185 - Revise CI scripts (#632, #635)
186 - Remove functionality already deprecated in 0.5 (#499)
187 - Support for `i128` and `u128` is automatically enabled for Rust >= 1.26. This
188 renders the `i128_support` feature obsolete. It still exists for backwards
189 compatibility but does not have any effect. This breaks programs using Rand
190 with `i128_support` on nightlies older than Rust 1.26. (#571)
193 ## [0.5.5] - 2018-08-07
195 - Fix links in documentation (#582)
198 ## [0.5.4] - 2018-07-11
200 - Make `OsRng` work via WASM/stdweb for WebWorkers
203 ## [0.5.3] - 2018-06-26
205 - OpenBSD, Bitrig: fix compilation (broken in 0.5.1) (#530)
208 ## [0.5.2] - 2018-06-18
210 - Hide `OsRng` and `JitterRng` on unsupported platforms (#512; fixes #503).
213 ## [0.5.1] - 2018-06-08
215 ### New distributions
216 - Added Cauchy distribution. (#474, #486)
217 - Added Pareto distribution. (#495)
219 ### Platform support and `OsRng`
220 - Remove blanket Unix implementation. (#484)
221 - Remove Wasm unimplemented stub. (#484)
222 - Dragonfly BSD: read from `/dev/random`. (#484)
223 - Bitrig: use `getentropy` like OpenBSD. (#484)
224 - Solaris: (untested) use `getrandom` if available, otherwise `/dev/random`. (#484)
225 - Emscripten, `stdweb`: split the read up in chunks. (#484)
226 - Emscripten, Haiku: don't do an extra blocking read from `/dev/random`. (#484)
227 - Linux, NetBSD, Solaris: read in blocking mode on first use in `fill_bytes`. (#484)
228 - Fuchsia, CloudABI: fix compilation (broken in Rand 0.5). (#484)
231 ## [0.5.0] - 2018-05-21
233 ### Crate features and organisation
234 - Minimum Rust version update: 1.22.0. (#239)
235 - Create a separate `rand_core` crate. (#288)
236 - Deprecate `rand_derive`. (#256)
237 - Add `prelude` (and module reorganisation). (#435)
238 - Add `log` feature. Logging is now available in `JitterRng`, `OsRng`, `EntropyRng` and `ReseedingRng`. (#246)
239 - Add `serde1` feature for some PRNGs. (#189)
240 - `stdweb` feature for `OsRng` support on WASM via stdweb. (#272, #336)
243 - Split `Rng` in `RngCore` and `Rng` extension trait.
244 `next_u32`, `next_u64` and `fill_bytes` are now part of `RngCore`. (#265)
245 - Add `Rng::sample`. (#256)
246 - Deprecate `Rng::gen_weighted_bool`. (#308)
247 - Add `Rng::gen_bool`. (#308)
248 - Remove `Rng::next_f32` and `Rng::next_f64`. (#273)
249 - Add optimized `Rng::fill` and `Rng::try_fill` methods. (#247)
250 - Deprecate `Rng::gen_iter`. (#286)
251 - Deprecate `Rng::gen_ascii_chars`. (#279)
253 ### `rand_core` crate
254 - `rand` now depends on new `rand_core` crate (#288)
255 - `RngCore` and `SeedableRng` are now part of `rand_core`. (#288)
256 - Add modules to help implementing RNGs `impl` and `le`. (#209, #228)
257 - Add `Error` and `ErrorKind`. (#225)
258 - Add `CryptoRng` marker trait. (#273)
259 - Add `BlockRngCore` trait. (#281)
260 - Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325)
261 - Revise the `SeedableRng` trait. (#233)
262 - Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288)
263 - Add `RngCore::try_fill_bytes`. (#225)
265 ### Other traits and types
266 - Add `FromEntropy` trait. (#233, #375)
267 - Add `SmallRng` wrapper. (#296)
268 - Rewrite `ReseedingRng` to only work with `BlockRngCore` (substantial performance improvement). (#281)
269 - Deprecate `weak_rng`. Use `SmallRng` instead. (#296)
270 - Deprecate `AsciiGenerator`. (#279)
272 ### Random number generators
273 - Switch `StdRng` and `thread_rng` to HC-128. (#277)
274 - `StdRng` must now be created with `from_entropy` instead of `new`
275 - Change `thread_rng` reseeding threshold to 32 MiB. (#277)
276 - PRNGs no longer implement `Copy`. (#209)
277 - `Debug` implementations no longer show internals. (#209)
278 - Implement `Clone` for `ReseedingRng`, `JitterRng`, OsRng`. (#383, #384)
279 - Implement serialization for `XorShiftRng`, `IsaacRng` and `Isaac64Rng` under the `serde1` feature. (#189)
280 - Implement `BlockRngCore` for `ChaChaCore` and `Hc128Core`. (#281)
281 - All PRNGs are now portable across big- and little-endian architectures. (#209)
282 - `Isaac64Rng::next_u32` no longer throws away half the results. (#209)
283 - Add `IsaacRng::new_from_u64` and `Isaac64Rng::new_from_u64`. (#209)
284 - Add the HC-128 CSPRNG `Hc128Rng`. (#210)
285 - Change ChaCha20 to have 64-bit counter and 64-bit stream. (#349)
286 - Changes to `JitterRng` to get its size down from 2112 to 24 bytes. (#251)
287 - Various performance improvements to all PRNGs.
289 ### Platform support and `OsRng`
290 - Add support for CloudABI. (#224)
291 - Remove support for NaCl. (#225)
292 - WASM support for `OsRng` via stdweb, behind the `stdweb` feature. (#272, #336)
293 - Use `getrandom` on more platforms for Linux, and on Android. (#338)
294 - Use the `SecRandomCopyBytes` interface on macOS. (#322)
295 - On systems that do not have a syscall interface, only keep a single file descriptor open for `OsRng`. (#239)
296 - On Unix, first try a single read from `/dev/random`, then `/dev/urandom`. (#338)
297 - Better error handling and reporting in `OsRng` (using new error type). (#225)
298 - `OsRng` now uses non-blocking when available. (#225)
299 - Add `EntropyRng`, which provides `OsRng`, but has `JitterRng` as a fallback. (#235)
302 - New `Distribution` trait. (#256)
303 - Add `Distribution::sample_iter` and `Rng::::sample_iter`. (#361)
304 - Deprecate `Rand`, `Sample` and `IndependentSample` traits. (#256)
305 - Add a `Standard` distribution (replaces most `Rand` implementations). (#256)
306 - Add `Binomial` and `Poisson` distributions. (#96)
307 - Add `Bernoulli` dsitribution. (#411)
308 - Add `Alphanumeric` distribution. (#279)
309 - Remove `Closed01` distribution, add `OpenClosed01`. (#274, #420)
310 - Rework `Range` type, making it possible to implement it for user types. (#274)
311 - Rename `Range` to `Uniform`. (#395)
312 - Add `Uniform::new_inclusive` for inclusive ranges. (#274)
313 - Use widening multiply method for much faster integer range reduction. (#274)
314 - `Standard` distribution for `char` uses `Uniform` internally. (#274)
315 - `Standard` distribution for `bool` uses sign test. (#274)
316 - Implement `Standard` distribution for `Wrapping<T>`. (#436)
317 - Implement `Uniform` distribution for `Duration`. (#427)
320 ## [0.4.3] - 2018-08-16
322 - Use correct syscall number for PowerPC (#589)
325 ## [0.4.2] - 2018-01-06
327 - Use `winapi` on Windows
328 - Update for Fuchsia OS
329 - Remove dev-dependency on `log`
332 ## [0.4.1] - 2017-12-17
337 ## [0.4.0-pre.0] - 2017-12-11
339 - `JitterRng` added as a high-quality alternative entropy source using the
341 - new `seq` module with `sample_iter`, `sample_slice`, etc.
342 - WASM support via dummy implementations (fail at run-time)
343 - Additional benchmarks, covering generators and new seq code
346 - `thread_rng` uses `JitterRng` if seeding from system time fails
347 (slower but more secure than previous method)
350 - `sample` function deprecated (replaced by `sample_iter`)
353 ## [0.3.20] - 2018-01-06
355 - Remove dev-dependency on `log`
356 - Update `fuchsia-zircon` dependency to 0.3.2
359 ## [0.3.19] - 2017-12-27
361 - Require `log <= 0.3.8` for dev builds
362 - Update `fuchsia-zircon` dependency to 0.3
363 - Fix broken links in docs (to unblock compiler docs testing CI)
366 ## [0.3.18] - 2017-11-06
368 - `thread_rng` is seeded from the system time if `OsRng` fails
369 - `weak_rng` now uses `thread_rng` internally
372 ## [0.3.17] - 2017-10-07
374 - Fuchsia: Magenta was renamed Zircon
376 ## [0.3.16] - 2017-07-27
378 - Implement Debug for mote non-public types
379 - implement `Rand` for (i|u)i128
380 - Support for Fuchsia
383 - Add inline attribute to SampleRange::construct_range.
384 This improves the benchmark for sample in 11% and for shuffle in 16%.
385 - Use `RtlGenRandom` instead of `CryptGenRandom`
388 ## [0.3.15] - 2016-11-26
390 - Add `Rng` trait method `choose_mut`
394 - Use `arc4rand` for `OsRng` on FreeBSD.
395 - Use `arc4random(3)` for `OsRng` on OpenBSD.
398 - Fix filling buffers 4 GiB or larger with `OsRng::fill_bytes` on Windows
401 ## [0.3.14] - 2016-02-13
403 - Inline definitions from winapi/advapi32, wich decreases build times
406 ## [0.3.13] - 2016-01-09
408 - Compatible with Rust 1.7.0-nightly (needed some extra type annotations)
411 ## [0.3.12] - 2015-11-09
413 - Replaced the methods in `next_f32` and `next_f64` with the technique described
414 Saito & Matsumoto at MCQMC'08. The new method should exhibit a slightly more
415 uniform distribution.
419 - Fix iterator protocol issue in `rand::sample`
422 ## [0.3.11] - 2015-08-31
424 - Implement `Rand` for arrays with n <= 32
427 ## [0.3.10] - 2015-08-17
429 - Support for NaCl platforms
432 - Allow `Rng` to be `?Sized`, impl for `&mut R` and `Box<R>` where `R: ?Sized + Rng`
435 ## [0.3.9] - 2015-06-18
437 - Use `winapi` for Windows API things
440 - Fixed test on stable/nightly
441 - Fix `getrandom` syscall number for aarch64-unknown-linux-gnu
444 ## [0.3.8] - 2015-04-23
446 - `log` is a dev dependency
449 - Fix race condition of atomics in `is_getrandom_available`
452 ## [0.3.7] - 2015-04-03
454 - Derive Copy/Clone changes
457 ## [0.3.6] - 2015-04-02
459 - Move to stable Rust!
462 ## [0.3.5] - 2015-04-01
464 - Compatible with Rust master
467 ## [0.3.4] - 2015-03-31
469 - Implement Clone for `Weighted`
472 - Compatible with Rust master
475 ## [0.3.3] - 2015-03-26
477 - Fix compile on Windows
480 ## [0.3.2] - 2015-03-26
483 ## [0.3.1] - 2015-03-26
485 - Fix compile on Windows
488 ## [0.3.0] - 2015-03-25
490 - Update to use log version 0.3.x
493 ## [0.2.1] - 2015-03-22
495 - Compatible with Rust master
496 - Fixed iOS compilation
499 ## [0.2.0] - 2015-03-06
501 - Compatible with Rust master (move from `old_io` to `std::io`)
504 ## [0.1.4] - 2015-03-04
506 - Compatible with Rust master (use wrapping ops)
509 ## [0.1.3] - 2015-02-20
511 - Compatible with Rust master
514 - Removed Copy implementations from RNGs
517 ## [0.1.2] - 2015-02-03
519 - Imported functionality from `std::rand`, including:
520 - `StdRng`, `SeedableRng`, `TreadRng`, `weak_rng()`
521 - `ReaderRng`: A wrapper around any Reader to treat it as an RNG.
522 - Imported documentation from `std::rand`
523 - Imported tests from `std::rand`
526 ## [0.1.1] - 2015-02-03
528 - Migrate to a cargo-compatible directory structure.
531 - Do not use entropy during `gen_weighted_bool(1)`
534 ## [Rust 0.12.0] - 2014-10-09
536 - Impl Rand for tuples of arity 11 and 12
537 - Include ChaCha pseudorandom generator
538 - Add `next_f64` and `next_f32` to Rng
539 - Implement Clone for PRNGs
542 - Rename `TaskRng` to `ThreadRng` and `task_rng` to `thread_rng` (since a
543 runtime is removed from Rust).
546 - Improved performance of ISAAC and ISAAC64 by 30% and 12 % respectively, by
547 informing the optimiser that indexing is never out-of-bounds.
550 - Removed the Deprecated `choose_option`
553 ## [Rust 0.11.0] - 2014-07-02
555 - document when to use `OSRng` in cryptographic context, and explain why we use `/dev/urandom` instead of `/dev/random`
556 - `Rng::gen_iter()` which will return an infinite stream of random values
557 - `Rng::gen_ascii_chars()` which will return an infinite stream of random ascii characters
560 - Now only depends on libcore!
561 - Remove `Rng.choose()`, rename `Rng.choose_option()` to `.choose()`
562 - Rename OSRng to OsRng
563 - The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`,
564 but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice
565 structure now has a lifetime associated with it.
566 - The `sample` method on `Rng` has been moved to a top-level function in the
567 `rand` module due to its dependence on `Vec`.
570 - `Rng::gen_vec()` was removed. Previous behavior can be regained with
571 `rng.gen_iter().take(n).collect()`
572 - `Rng::gen_ascii_str()` was removed. Previous behavior can be regained with
573 `rng.gen_ascii_chars().take(n).collect()`
574 - {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all
575 relied on being able to use an OSRng for seeding, but this is no longer
576 available in librand (where these types are defined). To retain the same
577 functionality, these types now implement the `Rand` trait so they can be
578 generated with a random seed from another random number generator. This allows
579 the stdlib to use an OSRng to create seeded instances of these RNGs.
580 - Rand implementations for `Box<T>` and `@T` were removed. These seemed to be
581 pretty rare in the codebase, and it allows for librand to not depend on
582 liballoc. Additionally, other pointer types like Rc<T> and Arc<T> were not
584 - Remove a slew of old deprecated functions
587 ## [Rust 0.10] - 2014-04-03
589 - replace `Rng.shuffle's` functionality with `.shuffle_mut`
590 - bubble up IO errors when creating an OSRng
593 - Use `fill()` instead of `read()`
594 - Rewrite OsRng in Rust for windows
596 ## [0.10-pre] - 2014-03-02
598 - Seperate `rand` out of the standard library