1# Changelog 2All notable changes to this project will be documented in this file. 3 4The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) 5and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 7A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md). 8 9You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful. 10 11## [0.7.3] - 2020-01-10 12### Fixes 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 17 18### Changes 19- Unix: make libc dependency optional; only use fork protection with std feature (#928) 20 21### Additions 22- Implement `std::error::Error` for `BernoulliError` (#919) 23 24## [0.7.2] - 2019-09-16 25### Fixes 26- Fix dependency on `rand_core` 0.5.1 (#890) 27 28### Additions 29- Unit tests for value stability of distributions added (#888) 30 31## [0.7.1] - 2019-09-13 32### Yanked 33This release was yanked since it depends on `rand_core::OsRng` added in 0.5.1 34but specifies a dependency on version 0.5.0 (#890), causing a broken builds 35when updating from `rand 0.7.0` without also updating `rand_core`. 36 37### Fixes 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) 41 42### Additions 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) 45 46## [0.7.0] - 2019-06-28 47 48### Fixes 49- Fix incorrect pointer usages revealed by Miri testing (#780, #781) 50- Fix (tiny!) bias in `Uniform` for 8- and 16-bit ints (#809) 51 52### Crate 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 61 62### rand_core 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) 67 68### Standard RNGs 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) 75 76### Distributions 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) 84 85### Sequences 86- Make results portable across 32- and 64-bit by using `u32` samples for `usize` where possible (#809) 87 88## [0.6.5] - 2019-01-28 89### Crates 90- Update `rand_core` to 0.4 (#703) 91- Move `JitterRng` to its own crate (#685) 92- Add a wasm-bindgen test crate (#696) 93 94### Platforms 95- Fuchsia: Replaced fuchsia-zircon with fuchsia-cprng 96 97### Doc 98- Use RFC 1946 for doc links (#691) 99- Fix some doc links and notes (#711) 100 101## [0.6.4] - 2019-01-08 102### Fixes 103- Move wasm-bindgen shims to correct crate (#686) 104- Make `wasm32-unknown-unknown` compile but fail at run-time if missing bindingsg (#686) 105 106## [0.6.3] - 2019-01-04 107### Fixes 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) 110 111## [0.6.2] - 2019-01-04 112### Additions 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) 116 117### Fixes 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) 122 123### Optimisations 124- Optimise memory usage of `UnitCircle` and `UnitSphereSurface` distributions (no PR) 125 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) 129 130## [0.6.0] - 2018-11-14 131 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) 139 140### Platforms 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) 145 146### RNGs 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) 153 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) 161 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) 168 169#### Optimisations 170 171- Optimise `Bernoulli::new` (#500) 172- Optimise `char` sampling (#519) 173- Optimise sampling of `std::time::Duration` (#583) 174 175### Sequences 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) 180 181### SIMD 182- Support for generating SIMD types (#523, #542, #561, #630) 183 184### Other 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) 191 192 193## [0.5.5] - 2018-08-07 194### Documentation 195- Fix links in documentation (#582) 196 197 198## [0.5.4] - 2018-07-11 199### Platform support 200- Make `OsRng` work via WASM/stdweb for WebWorkers 201 202 203## [0.5.3] - 2018-06-26 204### Platform support 205- OpenBSD, Bitrig: fix compilation (broken in 0.5.1) (#530) 206 207 208## [0.5.2] - 2018-06-18 209### Platform support 210- Hide `OsRng` and `JitterRng` on unsupported platforms (#512; fixes #503). 211 212 213## [0.5.1] - 2018-06-08 214 215### New distributions 216- Added Cauchy distribution. (#474, #486) 217- Added Pareto distribution. (#495) 218 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) 229 230 231## [0.5.0] - 2018-05-21 232 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) 241 242### `Rng` trait 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) 252 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) 264 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) 271 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. 288 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) 300 301### Distributions 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) 318 319 320## [0.4.3] - 2018-08-16 321### Fixed 322- Use correct syscall number for PowerPC (#589) 323 324 325## [0.4.2] - 2018-01-06 326### Changed 327- Use `winapi` on Windows 328- Update for Fuchsia OS 329- Remove dev-dependency on `log` 330 331 332## [0.4.1] - 2017-12-17 333### Added 334- `no_std` support 335 336 337## [0.4.0-pre.0] - 2017-12-11 338### Added 339- `JitterRng` added as a high-quality alternative entropy source using the 340 system timer 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 344 345### Changed 346- `thread_rng` uses `JitterRng` if seeding from system time fails 347 (slower but more secure than previous method) 348 349### Deprecated 350 - `sample` function deprecated (replaced by `sample_iter`) 351 352 353## [0.3.20] - 2018-01-06 354### Changed 355- Remove dev-dependency on `log` 356- Update `fuchsia-zircon` dependency to 0.3.2 357 358 359## [0.3.19] - 2017-12-27 360### Changed 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) 364 365 366## [0.3.18] - 2017-11-06 367### Changed 368- `thread_rng` is seeded from the system time if `OsRng` fails 369- `weak_rng` now uses `thread_rng` internally 370 371 372## [0.3.17] - 2017-10-07 373### Changed 374 - Fuchsia: Magenta was renamed Zircon 375 376## [0.3.16] - 2017-07-27 377### Added 378- Implement Debug for mote non-public types 379- implement `Rand` for (i|u)i128 380- Support for Fuchsia 381 382### Changed 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` 386 387 388## [0.3.15] - 2016-11-26 389### Added 390- Add `Rng` trait method `choose_mut` 391- Redox support 392 393### Changed 394- Use `arc4rand` for `OsRng` on FreeBSD. 395- Use `arc4random(3)` for `OsRng` on OpenBSD. 396 397### Fixed 398- Fix filling buffers 4 GiB or larger with `OsRng::fill_bytes` on Windows 399 400 401## [0.3.14] - 2016-02-13 402### Fixed 403- Inline definitions from winapi/advapi32, wich decreases build times 404 405 406## [0.3.13] - 2016-01-09 407### Fixed 408- Compatible with Rust 1.7.0-nightly (needed some extra type annotations) 409 410 411## [0.3.12] - 2015-11-09 412### Changed 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. 416- Depend on libc 0.2 417 418### Fixed 419- Fix iterator protocol issue in `rand::sample` 420 421 422## [0.3.11] - 2015-08-31 423### Added 424- Implement `Rand` for arrays with n <= 32 425 426 427## [0.3.10] - 2015-08-17 428### Added 429- Support for NaCl platforms 430 431### Changed 432- Allow `Rng` to be `?Sized`, impl for `&mut R` and `Box<R>` where `R: ?Sized + Rng` 433 434 435## [0.3.9] - 2015-06-18 436### Changed 437- Use `winapi` for Windows API things 438 439### Fixed 440- Fixed test on stable/nightly 441- Fix `getrandom` syscall number for aarch64-unknown-linux-gnu 442 443 444## [0.3.8] - 2015-04-23 445### Changed 446- `log` is a dev dependency 447 448### Fixed 449- Fix race condition of atomics in `is_getrandom_available` 450 451 452## [0.3.7] - 2015-04-03 453### Fixed 454- Derive Copy/Clone changes 455 456 457## [0.3.6] - 2015-04-02 458### Changed 459- Move to stable Rust! 460 461 462## [0.3.5] - 2015-04-01 463### Fixed 464- Compatible with Rust master 465 466 467## [0.3.4] - 2015-03-31 468### Added 469- Implement Clone for `Weighted` 470 471### Fixed 472- Compatible with Rust master 473 474 475## [0.3.3] - 2015-03-26 476### Fixed 477- Fix compile on Windows 478 479 480## [0.3.2] - 2015-03-26 481 482 483## [0.3.1] - 2015-03-26 484### Fixed 485- Fix compile on Windows 486 487 488## [0.3.0] - 2015-03-25 489### Changed 490- Update to use log version 0.3.x 491 492 493## [0.2.1] - 2015-03-22 494### Fixed 495- Compatible with Rust master 496- Fixed iOS compilation 497 498 499## [0.2.0] - 2015-03-06 500### Fixed 501- Compatible with Rust master (move from `old_io` to `std::io`) 502 503 504## [0.1.4] - 2015-03-04 505### Fixed 506- Compatible with Rust master (use wrapping ops) 507 508 509## [0.1.3] - 2015-02-20 510### Fixed 511- Compatible with Rust master 512 513### Removed 514- Removed Copy implementations from RNGs 515 516 517## [0.1.2] - 2015-02-03 518### Added 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` 524 525 526## [0.1.1] - 2015-02-03 527### Added 528- Migrate to a cargo-compatible directory structure. 529 530### Fixed 531- Do not use entropy during `gen_weighted_bool(1)` 532 533 534## [Rust 0.12.0] - 2014-10-09 535### Added 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 540 541### Changed 542- Rename `TaskRng` to `ThreadRng` and `task_rng` to `thread_rng` (since a 543 runtime is removed from Rust). 544 545### Fixed 546- Improved performance of ISAAC and ISAAC64 by 30% and 12 % respectively, by 547 informing the optimiser that indexing is never out-of-bounds. 548 549### Removed 550- Removed the Deprecated `choose_option` 551 552 553## [Rust 0.11.0] - 2014-07-02 554### Added 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 558 559### Changed 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`. 568 569### Removed 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 583 supported. 584- Remove a slew of old deprecated functions 585 586 587## [Rust 0.10] - 2014-04-03 588### Changed 589- replace `Rng.shuffle's` functionality with `.shuffle_mut` 590- bubble up IO errors when creating an OSRng 591 592### Fixed 593- Use `fill()` instead of `read()` 594- Rewrite OsRng in Rust for windows 595 596## [0.10-pre] - 2014-03-02 597### Added 598- Seperate `rand` out of the standard library 599