| 1 | # Changelog |
| 2 | All notable changes to this project will be documented in this file. |
| 3 | |
| 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). |
| 6 | |
| 7 | A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md). |
| 8 | |
| 9 | You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful. |
| 10 | |
| 11 | ## [0.9.2 — 2025-07-20] |
| 12 | ### Deprecated |
| 13 | - Deprecate `rand::rngs::mock` module and `StepRng` generator (#1634) |
| 14 | |
| 15 | ### Additions |
| 16 | - Enable `WeightedIndex<usize>` (de)serialization (#1646) |
| 17 | |
| 18 | ## [0.9.1] - 2025-04-17 |
| 19 | ### Security and unsafe |
| 20 | - Revise "not a crypto library" policy again (#1565) |
| 21 | - Remove `zerocopy` dependency from `rand` (#1579) |
| 22 | |
| 23 | ### Fixes |
| 24 | - Fix feature `simd_support` for recent nightly rust (#1586) |
| 25 | |
| 26 | ### Changes |
| 27 | - Allow `fn rand::seq::index::sample_weighted` and `fn IndexedRandom::choose_multiple_weighted` to return fewer than `amount` results (#1623), reverting an undocumented change (#1382) to the previous release. |
| 28 | |
| 29 | ### Additions |
| 30 | - Add `rand::distr::Alphabetic` distribution. (#1587) |
| 31 | - Re-export `rand_core` (#1604) |
| 32 | |
| 33 | ## [0.9.0] - 2025-01-27 |
| 34 | ### Security and unsafe |
| 35 | - Policy: "rand is not a crypto library" (#1514) |
| 36 | - Remove fork-protection from `ReseedingRng` and `ThreadRng`. Instead, it is recommended to call `ThreadRng::reseed` on fork. (#1379) |
| 37 | - Use `zerocopy` to replace some `unsafe` code (#1349, #1393, #1446, #1502) |
| 38 | |
| 39 | ### Dependencies |
| 40 | - Bump the MSRV to 1.63.0 (#1207, #1246, #1269, #1341, #1416, #1536); note that 1.60.0 may work for dependents when using `--ignore-rust-version` |
| 41 | - Update to `rand_core` v0.9.0 (#1558) |
| 42 | |
| 43 | ### Features |
| 44 | - Support `std` feature without `getrandom` or `rand_chacha` (#1354) |
| 45 | - Enable feature `small_rng` by default (#1455) |
| 46 | - Remove implicit feature `rand_chacha`; use `std_rng` instead. (#1473) |
| 47 | - Rename feature `serde1` to `serde` (#1477) |
| 48 | - Rename feature `getrandom` to `os_rng` (#1537) |
| 49 | - Add feature `thread_rng` (#1547) |
| 50 | |
| 51 | ### API changes: rand_core traits |
| 52 | - Add fn `RngCore::read_adapter` implementing `std::io::Read` (#1267) |
| 53 | - Add trait `CryptoBlockRng: BlockRngCore`; make `trait CryptoRng: RngCore` (#1273) |
| 54 | - Add traits `TryRngCore`, `TryCryptoRng` (#1424, #1499) |
| 55 | - Rename `fn SeedableRng::from_rng` -> `try_from_rng` and add infallible variant `fn from_rng` (#1424) |
| 56 | - Rename `fn SeedableRng::from_entropy` -> `from_os_rng` and add fallible variant `fn try_from_os_rng` (#1424) |
| 57 | - Add bounds `Clone` and `AsRef` to associated type `SeedableRng::Seed` (#1491) |
| 58 | |
| 59 | ### API changes: Rng trait and top-level fns |
| 60 | - Rename fn `rand::thread_rng()` to `rand::rng()` and remove from the prelude (#1506) |
| 61 | - Remove fn `rand::random()` from the prelude (#1506) |
| 62 | - Add top-level fns `random_iter`, `random_range`, `random_bool`, `random_ratio`, `fill` (#1488) |
| 63 | - Re-introduce fn `Rng::gen_iter` as `random_iter` (#1305, #1500) |
| 64 | - Rename fn `Rng::gen` to `random` to avoid conflict with the new `gen` keyword in Rust 2024 (#1438) |
| 65 | - Rename fns `Rng::gen_range` to `random_range`, `gen_bool` to `random_bool`, `gen_ratio` to `random_ratio` (#1505) |
| 66 | - Annotate panicking methods with `#[track_caller]` (#1442, #1447) |
| 67 | |
| 68 | ### API changes: RNGs |
| 69 | - Fix `<SmallRng as SeedableRng>::Seed` size to 256 bits (#1455) |
| 70 | - Remove first parameter (`rng`) of `ReseedingRng::new` (#1533) |
| 71 | |
| 72 | ### API changes: Sequences |
| 73 | - Split trait `SliceRandom` into `IndexedRandom`, `IndexedMutRandom`, `SliceRandom` (#1382) |
| 74 | - Add `IndexedRandom::choose_multiple_array`, `index::sample_array` (#1453, #1469) |
| 75 | |
| 76 | ### API changes: Distributions: renames |
| 77 | - Rename module `rand::distributions` to `rand::distr` (#1470) |
| 78 | - Rename distribution `Standard` to `StandardUniform` (#1526) |
| 79 | - Move `distr::Slice` -> `distr::slice::Choose`, `distr::EmptySlice` -> `distr::slice::Empty` (#1548) |
| 80 | - Rename trait `distr::DistString` -> `distr::SampleString` (#1548) |
| 81 | - Rename `distr::DistIter` -> `distr::Iter`, `distr::DistMap` -> `distr::Map` (#1548) |
| 82 | |
| 83 | ### API changes: Distributions |
| 84 | - Relax `Sized` bound on `Distribution<T> for &D` (#1278) |
| 85 | - Remove impl of `Distribution<Option<T>>` for `StandardUniform` (#1526) |
| 86 | - Let distribution `StandardUniform` support all `NonZero*` types (#1332) |
| 87 | - Fns `{Uniform, UniformSampler}::{new, new_inclusive}` return a `Result` (instead of potentially panicking) (#1229) |
| 88 | - Distribution `Uniform` implements `TryFrom` instead of `From` for ranges (#1229) |
| 89 | - Add `UniformUsize` (#1487) |
| 90 | - Remove support for generating `isize` and `usize` values with `StandardUniform`, `Uniform` (except via `UniformUsize`) and `Fill` and usage as a `WeightedAliasIndex` weight (#1487) |
| 91 | - Add impl `DistString` for distributions `Slice<char>` and `Uniform<char>` (#1315) |
| 92 | - Add fn `Slice::num_choices` (#1402) |
| 93 | - Add fn `p()` for distribution `Bernoulli` to access probability (#1481) |
| 94 | |
| 95 | ### API changes: Weighted distributions |
| 96 | - Add `pub` module `rand::distr::weighted`, moving `WeightedIndex` there (#1548) |
| 97 | - Add trait `weighted::Weight`, allowing `WeightedIndex` to trap overflow (#1353) |
| 98 | - Add fns `weight, weights, total_weight` to distribution `WeightedIndex` (#1420) |
| 99 | - Rename enum `WeightedError` to `weighted::Error`, revising variants (#1382) and mark as `#[non_exhaustive]` (#1480) |
| 100 | |
| 101 | ### API changes: SIMD |
| 102 | - Switch to `std::simd`, expand SIMD & docs (#1239) |
| 103 | |
| 104 | ### Reproducibility-breaking changes |
| 105 | - Make `ReseedingRng::reseed` discard remaining data from the last block generated (#1379) |
| 106 | - Change fn `SmallRng::seed_from_u64` implementation (#1203) |
| 107 | - Allow `UniformFloat::new` samples and `UniformFloat::sample_single` to yield `high` (#1462) |
| 108 | - Fix portability of distribution `Slice` (#1469) |
| 109 | - Make `Uniform` for `usize` portable via `UniformUsize` (#1487) |
| 110 | - Fix `IndexdRandom::choose_multiple_weighted` for very small seeds and optimize for large input length / low memory (#1530) |
| 111 | |
| 112 | ### Reproducibility-breaking optimisations |
| 113 | - Optimize fn `sample_floyd`, affecting output of `rand::seq::index::sample` and `rand::seq::SliceRandom::choose_multiple` (#1277) |
| 114 | - New, faster algorithms for `IteratorRandom::choose` and `choose_stable` (#1268) |
| 115 | - New, faster algorithms for `SliceRandom::shuffle` and `partial_shuffle` (#1272) |
| 116 | - Optimize distribution `Uniform`: use Canon's method (single sampling) / Lemire's method (distribution sampling) for faster sampling (breaks value stability; #1287) |
| 117 | - Optimize fn `sample_single_inclusive` for floats (+~20% perf) (#1289) |
| 118 | |
| 119 | ### Other optimisations |
| 120 | - Improve `SmallRng` initialization performance (#1482) |
| 121 | - Optimise SIMD widening multiply (#1247) |
| 122 | |
| 123 | ### Other |
| 124 | - Add `Cargo.lock.msrv` file (#1275) |
| 125 | - Reformat with `rustfmt` and enforce (#1448) |
| 126 | - Apply Clippy suggestions and enforce (#1448, #1474) |
| 127 | - Move all benchmarks to new `benches` crate (#1329, #1439) and migrate to Criterion (#1490) |
| 128 | |
| 129 | ### Documentation |
| 130 | - Improve `ThreadRng` related docs (#1257) |
| 131 | - Docs: enable experimental `--generate-link-to-definition` feature (#1327) |
| 132 | - Better doc of crate features, use `doc_auto_cfg` (#1411, #1450) |
| 133 | |
| 134 | ## [0.8.5] - 2021-08-20 |
| 135 | ### Fixes |
| 136 | - Fix build on non-32/64-bit architectures (#1144) |
| 137 | - Fix "min_const_gen" feature for `no_std` (#1173) |
| 138 | - Check `libc::pthread_atfork` return value with panic on error (#1178) |
| 139 | - More robust reseeding in case `ReseedingRng` is used from a fork handler (#1178) |
| 140 | - Fix nightly: remove unused `slice_partition_at_index` feature (#1215) |
| 141 | - Fix nightly + `simd_support`: update `packed_simd` (#1216) |
| 142 | |
| 143 | ### Rngs |
| 144 | - `StdRng`: Switch from HC128 to ChaCha12 on emscripten (#1142). |
| 145 | We now use ChaCha12 on all platforms. |
| 146 | |
| 147 | ### Documentation |
| 148 | - Added docs about rand's use of const generics (#1150) |
| 149 | - Better random chars example (#1157) |
| 150 | |
| 151 | |
| 152 | ## [0.8.4] - 2021-06-15 |
| 153 | ### Additions |
| 154 | - Use const-generics to support arrays of all sizes (#1104) |
| 155 | - Implement `Clone` and `Copy` for `Alphanumeric` (#1126) |
| 156 | - Add `Distribution::map` to derive a distribution using a closure (#1129) |
| 157 | - Add `Slice` distribution (#1107) |
| 158 | - Add `DistString` trait with impls for `Standard` and `Alphanumeric` (#1133) |
| 159 | |
| 160 | ### Other |
| 161 | - Reorder asserts in `Uniform` float distributions for easier debugging of non-finite arguments |
| 162 | (#1094, #1108) |
| 163 | - Add range overflow check in `Uniform` float distributions (#1108) |
| 164 | - Deprecate `rngs::adapter::ReadRng` (#1130) |
| 165 | |
| 166 | ## [0.8.3] - 2021-01-25 |
| 167 | ### Fixes |
| 168 | - Fix `no-std` + `alloc` build by gating `choose_multiple_weighted` on `std` (#1088) |
| 169 | |
| 170 | ## [0.8.2] - 2021-01-12 |
| 171 | ### Fixes |
| 172 | - Fix panic in `UniformInt::sample_single_inclusive` and `Rng::gen_range` when |
| 173 | providing a full integer range (eg `0..=MAX`) (#1087) |
| 174 | |
| 175 | ## [0.8.1] - 2020-12-31 |
| 176 | ### Other |
| 177 | - Enable all stable features in the playground (#1081) |
| 178 | |
| 179 | ## [0.8.0] - 2020-12-18 |
| 180 | ### Platform support |
| 181 | - The minimum supported Rust version is now 1.36 (#1011) |
| 182 | - `getrandom` updated to v0.2 (#1041) |
| 183 | - Remove `wasm-bindgen` and `stdweb` feature flags. For details of WASM support, |
| 184 | see the [getrandom documentation](https://docs.rs/getrandom/latest). (#948) |
| 185 | - `ReadRng::next_u32` and `next_u64` now use little-Endian conversion instead |
| 186 | of native-Endian, affecting results on Big-Endian platforms (#1061) |
| 187 | - The `nightly` feature no longer implies the `simd_support` feature (#1048) |
| 188 | - Fix `simd_support` feature to work on current nightlies (#1056) |
| 189 | |
| 190 | ### Rngs |
| 191 | - `ThreadRng` is no longer `Copy` to enable safe usage within thread-local destructors (#1035) |
| 192 | - `gen_range(a, b)` was replaced with `gen_range(a..b)`. `gen_range(a..=b)` is |
| 193 | also supported. Note that `a` and `b` can no longer be references or SIMD types. (#744, #1003) |
| 194 | - Replace `AsByteSliceMut` with `Fill` and add support for `[bool], [char], [f32], [f64]` (#940) |
| 195 | - Restrict `rand::rngs::adapter` to `std` (#1027; see also #928) |
| 196 | - `StdRng`: add new `std_rng` feature flag (enabled by default, but might need |
| 197 | to be used if disabling default crate features) (#948) |
| 198 | - `StdRng`: Switch from ChaCha20 to ChaCha12 for better performance (#1028) |
| 199 | - `SmallRng`: Replace PCG algorithm with xoshiro{128,256}++ (#1038) |
| 200 | |
| 201 | ### Sequences |
| 202 | - Add `IteratorRandom::choose_stable` as an alternative to `choose` which does |
| 203 | not depend on size hints (#1057) |
| 204 | - Improve accuracy and performance of `IteratorRandom::choose` (#1059) |
| 205 | - Implement `IntoIterator` for `IndexVec`, replacing the `into_iter` method (#1007) |
| 206 | - Add value stability tests for `seq` module (#933) |
| 207 | |
| 208 | ### Misc |
| 209 | - Support `PartialEq` and `Eq` for `StdRng`, `SmallRng` and `StepRng` (#979) |
| 210 | - Added a `serde1` feature and added Serialize/Deserialize to `UniformInt` and `WeightedIndex` (#974) |
| 211 | - Drop some unsafe code (#962, #963, #1011) |
| 212 | - Reduce packaged crate size (#983) |
| 213 | - Migrate to GitHub Actions from Travis+AppVeyor (#1073) |
| 214 | |
| 215 | ### Distributions |
| 216 | - `Alphanumeric` samples bytes instead of chars (#935) |
| 217 | - `Uniform` now supports `char`, enabling `rng.gen_range('A'..='Z')` (#1068) |
| 218 | - Add `UniformSampler::sample_single_inclusive` (#1003) |
| 219 | |
| 220 | #### Weighted sampling |
| 221 | - Implement weighted sampling without replacement (#976, #1013) |
| 222 | - `rand::distributions::alias_method::WeightedIndex` was moved to `rand_distr::WeightedAliasIndex`. |
| 223 | The simpler alternative `rand::distribution::WeightedIndex` remains. (#945) |
| 224 | - Improve treatment of rounding errors in `WeightedIndex::update_weights` (#956) |
| 225 | - `WeightedIndex`: return error on NaN instead of panic (#1005) |
| 226 | |
| 227 | ### Documentation |
| 228 | - Document types supported by `random` (#994) |
| 229 | - Document notes on password generation (#995) |
| 230 | - Note that `SmallRng` may not be the best choice for performance and in some |
| 231 | other cases (#1038) |
| 232 | - Use `doc(cfg)` to annotate feature-gated items (#1019) |
| 233 | - Adjust README (#1065) |
| 234 | |
| 235 | ## [0.7.3] - 2020-01-10 |
| 236 | ### Fixes |
| 237 | - The `Bernoulli` distribution constructors now reports an error on NaN and on |
| 238 | `denominator == 0`. (#925) |
| 239 | - Use `std::sync::Once` to register fork handler, avoiding possible atomicity violation (#928) |
| 240 | - Fix documentation on the precision of generated floating-point values |
| 241 | |
| 242 | ### Changes |
| 243 | - Unix: make libc dependency optional; only use fork protection with std feature (#928) |
| 244 | |
| 245 | ### Additions |
| 246 | - Implement `std::error::Error` for `BernoulliError` (#919) |
| 247 | |
| 248 | ## [0.7.2] - 2019-09-16 |
| 249 | ### Fixes |
| 250 | - Fix dependency on `rand_core` 0.5.1 (#890) |
| 251 | |
| 252 | ### Additions |
| 253 | - Unit tests for value stability of distributions added (#888) |
| 254 | |
| 255 | ## [0.7.1] - 2019-09-13 |
| 256 | ### Yanked |
| 257 | This release was yanked since it depends on `rand_core::OsRng` added in 0.5.1 |
| 258 | but specifies a dependency on version 0.5.0 (#890), causing a broken builds |
| 259 | when updating from `rand 0.7.0` without also updating `rand_core`. |
| 260 | |
| 261 | ### Fixes |
| 262 | - Fix `no_std` behaviour, appropriately enable c2-chacha's `std` feature (#844) |
| 263 | - `alloc` feature in `no_std` is available since Rust 1.36 (#856) |
| 264 | - Fix or squelch issues from Clippy lints (#840) |
| 265 | |
| 266 | ### Additions |
| 267 | - Add a `no_std` target to CI to continuously evaluate `no_std` status (#844) |
| 268 | - `WeightedIndex`: allow adjusting a sub-set of weights (#866) |
| 269 | |
| 270 | ## [0.7.0] - 2019-06-28 |
| 271 | |
| 272 | ### Fixes |
| 273 | - Fix incorrect pointer usages revealed by Miri testing (#780, #781) |
| 274 | - Fix (tiny!) bias in `Uniform` for 8- and 16-bit ints (#809) |
| 275 | |
| 276 | ### Crate |
| 277 | - Bumped MSRV (min supported Rust version) to 1.32.0 |
| 278 | - Updated to Rust Edition 2018 (#823, #824) |
| 279 | - Removed dependence on `rand_xorshift`, `rand_isaac`, `rand_jitter` crates (#759, #765) |
| 280 | - Remove dependency on `winapi` (#724) |
| 281 | - Removed all `build.rs` files (#824) |
| 282 | - Removed code already deprecated in version 0.6 (#757) |
| 283 | - Removed the serde1 feature (It's still available for backwards compatibility, but it does not do anything. #830) |
| 284 | - Many documentation changes |
| 285 | |
| 286 | ### rand_core |
| 287 | - Updated to `rand_core` 0.5.0 |
| 288 | - `Error` type redesigned with new API (#800) |
| 289 | - Move `from_entropy` method to `SeedableRng` and remove `FromEntropy` (#800) |
| 290 | - `SeedableRng::from_rng` is now expected to be value-stable (#815) |
| 291 | |
| 292 | ### Standard RNGs |
| 293 | - OS interface moved from `rand_os` to new `getrandom` crate (#765, [getrandom](https://github.com/rust-random/getrandom)) |
| 294 | - Use ChaCha for `StdRng` and `ThreadRng` (#792) |
| 295 | - Feature-gate `SmallRng` (#792) |
| 296 | - `ThreadRng` now supports `Copy` (#758) |
| 297 | - Deprecated `EntropyRng` (#765) |
| 298 | - Enable fork protection of ReseedingRng without `std` (#724) |
| 299 | |
| 300 | ### Distributions |
| 301 | - Many distributions have been moved to `rand_distr` (#761) |
| 302 | - `Bernoulli::new` constructor now returns a `Result` (#803) |
| 303 | - `Distribution::sample_iter` adjusted for more flexibility (#758) |
| 304 | - Added `distributions::weighted::alias_method::WeightedIndex` for `O(1)` sampling (#692) |
| 305 | - Support sampling `NonZeroU*` types with the `Standard` distribution (#728) |
| 306 | - Optimised `Binomial` distribution sampling (#735, #740, #752) |
| 307 | - Optimised SIMD float sampling (#739) |
| 308 | |
| 309 | ### Sequences |
| 310 | - Make results portable across 32- and 64-bit by using `u32` samples for `usize` where possible (#809) |
| 311 | |
| 312 | ## [0.6.5] - 2019-01-28 |
| 313 | ### Crates |
| 314 | - Update `rand_core` to 0.4 (#703) |
| 315 | - Move `JitterRng` to its own crate (#685) |
| 316 | - Add a wasm-bindgen test crate (#696) |
| 317 | |
| 318 | ### Platforms |
| 319 | - Fuchsia: Replaced fuchsia-zircon with fuchsia-cprng |
| 320 | |
| 321 | ### Doc |
| 322 | - Use RFC 1946 for doc links (#691) |
| 323 | - Fix some doc links and notes (#711) |
| 324 | |
| 325 | ## [0.6.4] - 2019-01-08 |
| 326 | ### Fixes |
| 327 | - Move wasm-bindgen shims to correct crate (#686) |
| 328 | - Make `wasm32-unknown-unknown` compile but fail at run-time if missing bindingsg (#686) |
| 329 | |
| 330 | ## [0.6.3] - 2019-01-04 |
| 331 | ### Fixes |
| 332 | - Make the `std` feature require the optional `rand_os` dependency (#675) |
| 333 | - Re-export the optional WASM dependencies of `rand_os` from `rand` to avoid breakage (#674) |
| 334 | |
| 335 | ## [0.6.2] - 2019-01-04 |
| 336 | ### Additions |
| 337 | - Add `Default` for `ThreadRng` (#657) |
| 338 | - Move `rngs::OsRng` to `rand_os` sub-crate; clean up code; use as dependency (#643) ##BLOCKER## |
| 339 | - Add `rand_xoshiro` sub-crate, plus benchmarks (#642, #668) |
| 340 | |
| 341 | ### Fixes |
| 342 | - Fix bias in `UniformInt::sample_single` (#662) |
| 343 | - Use `autocfg` instead of `rustc_version` for rustc version detection (#664) |
| 344 | - Disable `i128` and `u128` if the `target_os` is `emscripten` (#671: work-around Emscripten limitation) |
| 345 | - CI fixes (#660, #671) |
| 346 | |
| 347 | ### Optimisations |
| 348 | - Optimise memory usage of `UnitCircle` and `UnitSphereSurface` distributions (no PR) |
| 349 | |
| 350 | ## [0.6.1] - 2018-11-22 |
| 351 | - Support sampling `Duration` also for `no_std` (only since Rust 1.25) (#649) |
| 352 | - Disable default features of `libc` (#647) |
| 353 | |
| 354 | ## [0.6.0] - 2018-11-14 |
| 355 | |
| 356 | ### Project organisation |
| 357 | - Rand has moved from [rust-lang-nursery](https://github.com/rust-lang-nursery/rand) |
| 358 | to [rust-random](https://github.com/rust-random/rand)! (#578) |
| 359 | - Created [The Rust Random Book](https://rust-random.github.io/book/) |
| 360 | ([source](https://github.com/rust-random/book)) |
| 361 | - Update copyright and licence notices (#591, #611) |
| 362 | - Migrate policy documentation from the wiki (#544) |
| 363 | |
| 364 | ### Platforms |
| 365 | - Add fork protection on Unix (#466) |
| 366 | - Added support for wasm-bindgen. (#541, #559, #562, #600) |
| 367 | - Enable `OsRng` for powerpc64, sparc and sparc64 (#609) |
| 368 | - Use `syscall` from `libc` on Linux instead of redefining it (#629) |
| 369 | |
| 370 | ### RNGs |
| 371 | - Switch `SmallRng` to use PCG (#623) |
| 372 | - Implement `Pcg32` and `Pcg64Mcg` generators (#632) |
| 373 | - Move ISAAC RNGs to a dedicated crate (#551) |
| 374 | - Move Xorshift RNG to its own crate (#557) |
| 375 | - Move ChaCha and HC128 RNGs to dedicated crates (#607, #636) |
| 376 | - Remove usage of `Rc` from `ThreadRng` (#615) |
| 377 | |
| 378 | ### Sampling and distributions |
| 379 | - Implement `Rng.gen_ratio()` and `Bernoulli::new_ratio()` (#491) |
| 380 | - Make `Uniform` strictly respect `f32` / `f64` high/low bounds (#477) |
| 381 | - Allow `gen_range` and `Uniform` to work on non-`Copy` types (#506) |
| 382 | - `Uniform` supports inclusive ranges: `Uniform::from(a..=b)`. This is |
| 383 | automatically enabled for Rust >= 1.27. (#566) |
| 384 | - Implement `TrustedLen` and `FusedIterator` for `DistIter` (#620) |
| 385 | |
| 386 | #### New distributions |
| 387 | - Add the `Dirichlet` distribution (#485) |
| 388 | - Added sampling from the unit sphere and circle. (#567) |
| 389 | - Implement the triangular distribution (#575) |
| 390 | - Implement the Weibull distribution (#576) |
| 391 | - Implement the Beta distribution (#574) |
| 392 | |
| 393 | #### Optimisations |
| 394 | |
| 395 | - Optimise `Bernoulli::new` (#500) |
| 396 | - Optimise `char` sampling (#519) |
| 397 | - Optimise sampling of `std::time::Duration` (#583) |
| 398 | |
| 399 | ### Sequences |
| 400 | - Redesign the `seq` module (#483, #515) |
| 401 | - Add `WeightedIndex` and `choose_weighted` (#518, #547) |
| 402 | - Optimised and changed return type of the `sample_indices` function. (#479) |
| 403 | - Use `Iterator::size_hint()` to speed up `IteratorRandom::choose` (#593) |
| 404 | |
| 405 | ### SIMD |
| 406 | - Support for generating SIMD types (#523, #542, #561, #630) |
| 407 | |
| 408 | ### Other |
| 409 | - Revise CI scripts (#632, #635) |
| 410 | - Remove functionality already deprecated in 0.5 (#499) |
| 411 | - Support for `i128` and `u128` is automatically enabled for Rust >= 1.26. This |
| 412 | renders the `i128_support` feature obsolete. It still exists for backwards |
| 413 | compatibility but does not have any effect. This breaks programs using Rand |
| 414 | with `i128_support` on nightlies older than Rust 1.26. (#571) |
| 415 | |
| 416 | |
| 417 | ## [0.5.5] - 2018-08-07 |
| 418 | ### Documentation |
| 419 | - Fix links in documentation (#582) |
| 420 | |
| 421 | |
| 422 | ## [0.5.4] - 2018-07-11 |
| 423 | ### Platform support |
| 424 | - Make `OsRng` work via WASM/stdweb for WebWorkers |
| 425 | |
| 426 | |
| 427 | ## [0.5.3] - 2018-06-26 |
| 428 | ### Platform support |
| 429 | - OpenBSD, Bitrig: fix compilation (broken in 0.5.1) (#530) |
| 430 | |
| 431 | |
| 432 | ## [0.5.2] - 2018-06-18 |
| 433 | ### Platform support |
| 434 | - Hide `OsRng` and `JitterRng` on unsupported platforms (#512; fixes #503). |
| 435 | |
| 436 | |
| 437 | ## [0.5.1] - 2018-06-08 |
| 438 | |
| 439 | ### New distributions |
| 440 | - Added Cauchy distribution. (#474, #486) |
| 441 | - Added Pareto distribution. (#495) |
| 442 | |
| 443 | ### Platform support and `OsRng` |
| 444 | - Remove blanket Unix implementation. (#484) |
| 445 | - Remove Wasm unimplemented stub. (#484) |
| 446 | - Dragonfly BSD: read from `/dev/random`. (#484) |
| 447 | - Bitrig: use `getentropy` like OpenBSD. (#484) |
| 448 | - Solaris: (untested) use `getrandom` if available, otherwise `/dev/random`. (#484) |
| 449 | - Emscripten, `stdweb`: split the read up in chunks. (#484) |
| 450 | - Emscripten, Haiku: don't do an extra blocking read from `/dev/random`. (#484) |
| 451 | - Linux, NetBSD, Solaris: read in blocking mode on first use in `fill_bytes`. (#484) |
| 452 | - Fuchsia, CloudABI: fix compilation (broken in Rand 0.5). (#484) |
| 453 | |
| 454 | |
| 455 | ## [0.5.0] - 2018-05-21 |
| 456 | |
| 457 | ### Crate features and organisation |
| 458 | - Minimum Rust version update: 1.22.0. (#239) |
| 459 | - Create a separate `rand_core` crate. (#288) |
| 460 | - Deprecate `rand_derive`. (#256) |
| 461 | - Add `prelude` (and module reorganisation). (#435) |
| 462 | - Add `log` feature. Logging is now available in `JitterRng`, `OsRng`, `EntropyRng` and `ReseedingRng`. (#246) |
| 463 | - Add `serde1` feature for some PRNGs. (#189) |
| 464 | - `stdweb` feature for `OsRng` support on WASM via stdweb. (#272, #336) |
| 465 | |
| 466 | ### `Rng` trait |
| 467 | - Split `Rng` in `RngCore` and `Rng` extension trait. |
| 468 | `next_u32`, `next_u64` and `fill_bytes` are now part of `RngCore`. (#265) |
| 469 | - Add `Rng::sample`. (#256) |
| 470 | - Deprecate `Rng::gen_weighted_bool`. (#308) |
| 471 | - Add `Rng::gen_bool`. (#308) |
| 472 | - Remove `Rng::next_f32` and `Rng::next_f64`. (#273) |
| 473 | - Add optimized `Rng::fill` and `Rng::try_fill` methods. (#247) |
| 474 | - Deprecate `Rng::gen_iter`. (#286) |
| 475 | - Deprecate `Rng::gen_ascii_chars`. (#279) |
| 476 | |
| 477 | ### `rand_core` crate |
| 478 | - `rand` now depends on new `rand_core` crate (#288) |
| 479 | - `RngCore` and `SeedableRng` are now part of `rand_core`. (#288) |
| 480 | - Add modules to help implementing RNGs `impl` and `le`. (#209, #228) |
| 481 | - Add `Error` and `ErrorKind`. (#225) |
| 482 | - Add `CryptoRng` marker trait. (#273) |
| 483 | - Add `BlockRngCore` trait. (#281) |
| 484 | - Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325) |
| 485 | - Revise the `SeedableRng` trait. (#233) |
| 486 | - Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288) |
| 487 | - Add `RngCore::try_fill_bytes`. (#225) |
| 488 | |
| 489 | ### Other traits and types |
| 490 | - Add `FromEntropy` trait. (#233, #375) |
| 491 | - Add `SmallRng` wrapper. (#296) |
| 492 | - Rewrite `ReseedingRng` to only work with `BlockRngCore` (substantial performance improvement). (#281) |
| 493 | - Deprecate `weak_rng`. Use `SmallRng` instead. (#296) |
| 494 | - Deprecate `AsciiGenerator`. (#279) |
| 495 | |
| 496 | ### Random number generators |
| 497 | - Switch `StdRng` and `thread_rng` to HC-128. (#277) |
| 498 | - `StdRng` must now be created with `from_entropy` instead of `new` |
| 499 | - Change `thread_rng` reseeding threshold to 32 MiB. (#277) |
| 500 | - PRNGs no longer implement `Copy`. (#209) |
| 501 | - `Debug` implementations no longer show internals. (#209) |
| 502 | - Implement `Clone` for `ReseedingRng`, `JitterRng`, OsRng`. (#383, #384) |
| 503 | - Implement serialization for `XorShiftRng`, `IsaacRng` and `Isaac64Rng` under the `serde1` feature. (#189) |
| 504 | - Implement `BlockRngCore` for `ChaChaCore` and `Hc128Core`. (#281) |
| 505 | - All PRNGs are now portable across big- and little-endian architectures. (#209) |
| 506 | - `Isaac64Rng::next_u32` no longer throws away half the results. (#209) |
| 507 | - Add `IsaacRng::new_from_u64` and `Isaac64Rng::new_from_u64`. (#209) |
| 508 | - Add the HC-128 CSPRNG `Hc128Rng`. (#210) |
| 509 | - Change ChaCha20 to have 64-bit counter and 64-bit stream. (#349) |
| 510 | - Changes to `JitterRng` to get its size down from 2112 to 24 bytes. (#251) |
| 511 | - Various performance improvements to all PRNGs. |
| 512 | |
| 513 | ### Platform support and `OsRng` |
| 514 | - Add support for CloudABI. (#224) |
| 515 | - Remove support for NaCl. (#225) |
| 516 | - WASM support for `OsRng` via stdweb, behind the `stdweb` feature. (#272, #336) |
| 517 | - Use `getrandom` on more platforms for Linux, and on Android. (#338) |
| 518 | - Use the `SecRandomCopyBytes` interface on macOS. (#322) |
| 519 | - On systems that do not have a syscall interface, only keep a single file descriptor open for `OsRng`. (#239) |
| 520 | - On Unix, first try a single read from `/dev/random`, then `/dev/urandom`. (#338) |
| 521 | - Better error handling and reporting in `OsRng` (using new error type). (#225) |
| 522 | - `OsRng` now uses non-blocking when available. (#225) |
| 523 | - Add `EntropyRng`, which provides `OsRng`, but has `JitterRng` as a fallback. (#235) |
| 524 | |
| 525 | ### Distributions |
| 526 | - New `Distribution` trait. (#256) |
| 527 | - Add `Distribution::sample_iter` and `Rng::::sample_iter`. (#361) |
| 528 | - Deprecate `Rand`, `Sample` and `IndependentSample` traits. (#256) |
| 529 | - Add a `Standard` distribution (replaces most `Rand` implementations). (#256) |
| 530 | - Add `Binomial` and `Poisson` distributions. (#96) |
| 531 | - Add `Bernoulli` dsitribution. (#411) |
| 532 | - Add `Alphanumeric` distribution. (#279) |
| 533 | - Remove `Closed01` distribution, add `OpenClosed01`. (#274, #420) |
| 534 | - Rework `Range` type, making it possible to implement it for user types. (#274) |
| 535 | - Rename `Range` to `Uniform`. (#395) |
| 536 | - Add `Uniform::new_inclusive` for inclusive ranges. (#274) |
| 537 | - Use widening multiply method for much faster integer range reduction. (#274) |
| 538 | - `Standard` distribution for `char` uses `Uniform` internally. (#274) |
| 539 | - `Standard` distribution for `bool` uses sign test. (#274) |
| 540 | - Implement `Standard` distribution for `Wrapping<T>`. (#436) |
| 541 | - Implement `Uniform` distribution for `Duration`. (#427) |
| 542 | |
| 543 | |
| 544 | ## [0.4.3] - 2018-08-16 |
| 545 | ### Fixed |
| 546 | - Use correct syscall number for PowerPC (#589) |
| 547 | |
| 548 | |
| 549 | ## [0.4.2] - 2018-01-06 |
| 550 | ### Changed |
| 551 | - Use `winapi` on Windows |
| 552 | - Update for Fuchsia OS |
| 553 | - Remove dev-dependency on `log` |
| 554 | |
| 555 | |
| 556 | ## [0.4.1] - 2017-12-17 |
| 557 | ### Added |
| 558 | - `no_std` support |
| 559 | |
| 560 | |
| 561 | ## [0.4.0-pre.0] - 2017-12-11 |
| 562 | ### Added |
| 563 | - `JitterRng` added as a high-quality alternative entropy source using the |
| 564 | system timer |
| 565 | - new `seq` module with `sample_iter`, `sample_slice`, etc. |
| 566 | - WASM support via dummy implementations (fail at run-time) |
| 567 | - Additional benchmarks, covering generators and new seq code |
| 568 | |
| 569 | ### Changed |
| 570 | - `thread_rng` uses `JitterRng` if seeding from system time fails |
| 571 | (slower but more secure than previous method) |
| 572 | |
| 573 | ### Deprecated |
| 574 | - `sample` function deprecated (replaced by `sample_iter`) |
| 575 | |
| 576 | |
| 577 | ## [0.3.20] - 2018-01-06 |
| 578 | ### Changed |
| 579 | - Remove dev-dependency on `log` |
| 580 | - Update `fuchsia-zircon` dependency to 0.3.2 |
| 581 | |
| 582 | |
| 583 | ## [0.3.19] - 2017-12-27 |
| 584 | ### Changed |
| 585 | - Require `log <= 0.3.8` for dev builds |
| 586 | - Update `fuchsia-zircon` dependency to 0.3 |
| 587 | - Fix broken links in docs (to unblock compiler docs testing CI) |
| 588 | |
| 589 | |
| 590 | ## [0.3.18] - 2017-11-06 |
| 591 | ### Changed |
| 592 | - `thread_rng` is seeded from the system time if `OsRng` fails |
| 593 | - `weak_rng` now uses `thread_rng` internally |
| 594 | |
| 595 | |
| 596 | ## [0.3.17] - 2017-10-07 |
| 597 | ### Changed |
| 598 | - Fuchsia: Magenta was renamed Zircon |
| 599 | |
| 600 | ## [0.3.16] - 2017-07-27 |
| 601 | ### Added |
| 602 | - Implement Debug for mote non-public types |
| 603 | - implement `Rand` for (i|u)i128 |
| 604 | - Support for Fuchsia |
| 605 | |
| 606 | ### Changed |
| 607 | - Add inline attribute to SampleRange::construct_range. |
| 608 | This improves the benchmark for sample in 11% and for shuffle in 16%. |
| 609 | - Use `RtlGenRandom` instead of `CryptGenRandom` |
| 610 | |
| 611 | |
| 612 | ## [0.3.15] - 2016-11-26 |
| 613 | ### Added |
| 614 | - Add `Rng` trait method `choose_mut` |
| 615 | - Redox support |
| 616 | |
| 617 | ### Changed |
| 618 | - Use `arc4rand` for `OsRng` on FreeBSD. |
| 619 | - Use `arc4random(3)` for `OsRng` on OpenBSD. |
| 620 | |
| 621 | ### Fixed |
| 622 | - Fix filling buffers 4 GiB or larger with `OsRng::fill_bytes` on Windows |
| 623 | |
| 624 | |
| 625 | ## [0.3.14] - 2016-02-13 |
| 626 | ### Fixed |
| 627 | - Inline definitions from winapi/advapi32, which decreases build times |
| 628 | |
| 629 | |
| 630 | ## [0.3.13] - 2016-01-09 |
| 631 | ### Fixed |
| 632 | - Compatible with Rust 1.7.0-nightly (needed some extra type annotations) |
| 633 | |
| 634 | |
| 635 | ## [0.3.12] - 2015-11-09 |
| 636 | ### Changed |
| 637 | - Replaced the methods in `next_f32` and `next_f64` with the technique described |
| 638 | Saito & Matsumoto at MCQMC'08. The new method should exhibit a slightly more |
| 639 | uniform distribution. |
| 640 | - Depend on libc 0.2 |
| 641 | |
| 642 | ### Fixed |
| 643 | - Fix iterator protocol issue in `rand::sample` |
| 644 | |
| 645 | |
| 646 | ## [0.3.11] - 2015-08-31 |
| 647 | ### Added |
| 648 | - Implement `Rand` for arrays with n <= 32 |
| 649 | |
| 650 | |
| 651 | ## [0.3.10] - 2015-08-17 |
| 652 | ### Added |
| 653 | - Support for NaCl platforms |
| 654 | |
| 655 | ### Changed |
| 656 | - Allow `Rng` to be `?Sized`, impl for `&mut R` and `Box<R>` where `R: ?Sized + Rng` |
| 657 | |
| 658 | |
| 659 | ## [0.3.9] - 2015-06-18 |
| 660 | ### Changed |
| 661 | - Use `winapi` for Windows API things |
| 662 | |
| 663 | ### Fixed |
| 664 | - Fixed test on stable/nightly |
| 665 | - Fix `getrandom` syscall number for aarch64-unknown-linux-gnu |
| 666 | |
| 667 | |
| 668 | ## [0.3.8] - 2015-04-23 |
| 669 | ### Changed |
| 670 | - `log` is a dev dependency |
| 671 | |
| 672 | ### Fixed |
| 673 | - Fix race condition of atomics in `is_getrandom_available` |
| 674 | |
| 675 | |
| 676 | ## [0.3.7] - 2015-04-03 |
| 677 | ### Fixed |
| 678 | - Derive Copy/Clone changes |
| 679 | |
| 680 | |
| 681 | ## [0.3.6] - 2015-04-02 |
| 682 | ### Changed |
| 683 | - Move to stable Rust! |
| 684 | |
| 685 | |
| 686 | ## [0.3.5] - 2015-04-01 |
| 687 | ### Fixed |
| 688 | - Compatible with Rust master |
| 689 | |
| 690 | |
| 691 | ## [0.3.4] - 2015-03-31 |
| 692 | ### Added |
| 693 | - Implement Clone for `Weighted` |
| 694 | |
| 695 | ### Fixed |
| 696 | - Compatible with Rust master |
| 697 | |
| 698 | |
| 699 | ## [0.3.3] - 2015-03-26 |
| 700 | ### Fixed |
| 701 | - Fix compile on Windows |
| 702 | |
| 703 | |
| 704 | ## [0.3.2] - 2015-03-26 |
| 705 | |
| 706 | |
| 707 | ## [0.3.1] - 2015-03-26 |
| 708 | ### Fixed |
| 709 | - Fix compile on Windows |
| 710 | |
| 711 | |
| 712 | ## [0.3.0] - 2015-03-25 |
| 713 | ### Changed |
| 714 | - Update to use log version 0.3.x |
| 715 | |
| 716 | |
| 717 | ## [0.2.1] - 2015-03-22 |
| 718 | ### Fixed |
| 719 | - Compatible with Rust master |
| 720 | - Fixed iOS compilation |
| 721 | |
| 722 | |
| 723 | ## [0.2.0] - 2015-03-06 |
| 724 | ### Fixed |
| 725 | - Compatible with Rust master (move from `old_io` to `std::io`) |
| 726 | |
| 727 | |
| 728 | ## [0.1.4] - 2015-03-04 |
| 729 | ### Fixed |
| 730 | - Compatible with Rust master (use wrapping ops) |
| 731 | |
| 732 | |
| 733 | ## [0.1.3] - 2015-02-20 |
| 734 | ### Fixed |
| 735 | - Compatible with Rust master |
| 736 | |
| 737 | ### Removed |
| 738 | - Removed Copy implementations from RNGs |
| 739 | |
| 740 | |
| 741 | ## [0.1.2] - 2015-02-03 |
| 742 | ### Added |
| 743 | - Imported functionality from `std::rand`, including: |
| 744 | - `StdRng`, `SeedableRng`, `TreadRng`, `weak_rng()` |
| 745 | - `ReaderRng`: A wrapper around any Reader to treat it as an RNG. |
| 746 | - Imported documentation from `std::rand` |
| 747 | - Imported tests from `std::rand` |
| 748 | |
| 749 | |
| 750 | ## [0.1.1] - 2015-02-03 |
| 751 | ### Added |
| 752 | - Migrate to a cargo-compatible directory structure. |
| 753 | |
| 754 | ### Fixed |
| 755 | - Do not use entropy during `gen_weighted_bool(1)` |
| 756 | |
| 757 | |
| 758 | ## [Rust 0.12.0] - 2014-10-09 |
| 759 | ### Added |
| 760 | - Impl Rand for tuples of arity 11 and 12 |
| 761 | - Include ChaCha pseudorandom generator |
| 762 | - Add `next_f64` and `next_f32` to Rng |
| 763 | - Implement Clone for PRNGs |
| 764 | |
| 765 | ### Changed |
| 766 | - Rename `TaskRng` to `ThreadRng` and `task_rng` to `thread_rng` (since a |
| 767 | runtime is removed from Rust). |
| 768 | |
| 769 | ### Fixed |
| 770 | - Improved performance of ISAAC and ISAAC64 by 30% and 12 % respectively, by |
| 771 | informing the optimiser that indexing is never out-of-bounds. |
| 772 | |
| 773 | ### Removed |
| 774 | - Removed the Deprecated `choose_option` |
| 775 | |
| 776 | |
| 777 | ## [Rust 0.11.0] - 2014-07-02 |
| 778 | ### Added |
| 779 | - document when to use `OSRng` in cryptographic context, and explain why we use `/dev/urandom` instead of `/dev/random` |
| 780 | - `Rng::gen_iter()` which will return an infinite stream of random values |
| 781 | - `Rng::gen_ascii_chars()` which will return an infinite stream of random ascii characters |
| 782 | |
| 783 | ### Changed |
| 784 | - Now only depends on libcore! |
| 785 | - Remove `Rng.choose()`, rename `Rng.choose_option()` to `.choose()` |
| 786 | - Rename OSRng to OsRng |
| 787 | - The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`, |
| 788 | but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice |
| 789 | structure now has a lifetime associated with it. |
| 790 | - The `sample` method on `Rng` has been moved to a top-level function in the |
| 791 | `rand` module due to its dependence on `Vec`. |
| 792 | |
| 793 | ### Removed |
| 794 | - `Rng::gen_vec()` was removed. Previous behavior can be regained with |
| 795 | `rng.gen_iter().take(n).collect()` |
| 796 | - `Rng::gen_ascii_str()` was removed. Previous behavior can be regained with |
| 797 | `rng.gen_ascii_chars().take(n).collect()` |
| 798 | - {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all |
| 799 | relied on being able to use an OSRng for seeding, but this is no longer |
| 800 | available in librand (where these types are defined). To retain the same |
| 801 | functionality, these types now implement the `Rand` trait so they can be |
| 802 | generated with a random seed from another random number generator. This allows |
| 803 | the stdlib to use an OSRng to create seeded instances of these RNGs. |
| 804 | - Rand implementations for `Box<T>` and `@T` were removed. These seemed to be |
| 805 | pretty rare in the codebase, and it allows for librand to not depend on |
| 806 | liballoc. Additionally, other pointer types like Rc<T> and Arc<T> were not |
| 807 | supported. |
| 808 | - Remove a slew of old deprecated functions |
| 809 | |
| 810 | |
| 811 | ## [Rust 0.10] - 2014-04-03 |
| 812 | ### Changed |
| 813 | - replace `Rng.shuffle's` functionality with `.shuffle_mut` |
| 814 | - bubble up IO errors when creating an OSRng |
| 815 | |
| 816 | ### Fixed |
| 817 | - Use `fill()` instead of `read()` |
| 818 | - Rewrite OsRng in Rust for windows |
| 819 | |
| 820 | ## [0.10-pre] - 2014-03-02 |
| 821 | ### Added |
| 822 | - Separate `rand` out of the standard library |