diff --git a/CHANGELOG.md b/CHANGELOG.md index e8baa39e002..b37ca35a05f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,19 +8,19 @@ A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md). You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful. -## [Unreleased] +## [0.8.4] - 2021-06-15 ### Additions - Use const-generics to support arrays of all sizes (#1104) - Implement `Clone` and `Copy` for `Alphanumeric` (#1126) - Add `Distribution::map` to derive a distribution using a closure (#1129) +- Add `Slice` distribution (#1107) +- Add `DistString` trait with impls for `Standard` and `Alphanumeric` (#1133) ### Other - Reorder asserts in `Uniform` float distributions for easier debugging of non-finite arguments (#1094, #1108) - Add range overflow check in `Uniform` float distributions (#1108) - -### Distributions -- Add slice distribution (#1107) +- Deprecate `rngs::adapter::ReadRng` (#1130) ## [0.8.3] - 2021-01-25 ### Fixes @@ -678,4 +678,4 @@ when updating from `rand 0.7.0` without also updating `rand_core`. ## [0.10-pre] - 2014-03-02 ### Added -- Seperate `rand` out of the standard library +- Separate `rand` out of the standard library diff --git a/Cargo.toml b/Cargo.toml index 7111e48f6da..5ce312342cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rand" -version = "0.8.3" +version = "0.8.4" authors = ["The Rand Project Developers", "The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/README.md b/README.md index 355e53bdac9..2f313e39ca9 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ unavailable. The WASM target `wasm32-unknown-unknown` is not *automatically* supported by `rand` or `getrandom`. To solve this, either use a different target such as -`wasm32-wasi` or add a direct dependancy on `getrandom` with the `js` feature +`wasm32-wasi` or add a direct dependency on `getrandom` with the `js` feature (if the target supports JavaScript). See [getrandom#WebAssembly support](https://docs.rs/getrandom/latest/getrandom/#webassembly-support). diff --git a/SECURITY.md b/SECURITY.md index 0da2bf0fed6..bad366c1fd8 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -8,7 +8,7 @@ No binding guarantees can be provided. ## Security premises Rand provides the trait `rand_core::CryptoRng` aka `rand::CryptoRng` as a marker -trait. Generators implementating `RngCore` *and* `CryptoRng`, and given the +trait. Generators implementing `RngCore` *and* `CryptoRng`, and given the additional constraints that: - Instances of seedable RNGs (those implementing `SeedableRng`) are diff --git a/rand_core/CHANGELOG.md b/rand_core/CHANGELOG.md index 23d1fa5a1d3..82c830086cd 100644 --- a/rand_core/CHANGELOG.md +++ b/rand_core/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.6.3] - 2021-06-15 +### Changed +- Improved bound for `serde` impls on `BlockRng` (#1130) +- Minor doc additions (#1118) + ## [0.6.2] - 2021-02-12 ### Fixed - Fixed assertions in `le::read_u32_into` and `le::read_u64_into` which could diff --git a/rand_core/Cargo.toml b/rand_core/Cargo.toml index d460757d21d..6604bc5a8b1 100644 --- a/rand_core/Cargo.toml +++ b/rand_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rand_core" -version = "0.6.2" +version = "0.6.3" authors = ["The Rand Project Developers", "The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/rand_core/src/block.rs b/rand_core/src/block.rs index a54cadfed7d..5f48bfaf546 100644 --- a/rand_core/src/block.rs +++ b/rand_core/src/block.rs @@ -95,7 +95,7 @@ pub trait BlockRngCore { /// [`fill_bytes`] / [`try_fill_bytes`] is called on a large array. These methods /// also handle the bookkeeping of when to generate a new batch of values. /// -/// No whole generated `u32` values are thown away and all values are consumed +/// No whole generated `u32` values are thrown away and all values are consumed /// in-order. [`next_u32`] simply takes the next available `u32` value. /// [`next_u64`] is implemented by combining two `u32` values, least /// significant first. [`fill_bytes`] and [`try_fill_bytes`] consume a whole diff --git a/rand_distr/CHANGELOG.md b/rand_distr/CHANGELOG.md index 9b7ac93628d..e9d1391091b 100644 --- a/rand_distr/CHANGELOG.md +++ b/rand_distr/CHANGELOG.md @@ -4,12 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## [0.4.1] - 2021-06-15 +- Empirically test PDF of normal distribution (#1121) - Correctly document `no_std` support (#1100) - Add `std_math` feature to prefer `std` over `libm` for floating point math (#1100) - Add mean and std_dev accessors to Normal (#1114) - Make sure all distributions and their error types implement `Error`, `Display`, `Clone`, `Copy`, `PartialEq` and `Eq` as appropriate (#1126) +- Port benchmarks to use Criterion crate (#1116) - Support serde for distributions (#1141) ## [0.4.0] - 2020-12-18 diff --git a/rand_distr/Cargo.toml b/rand_distr/Cargo.toml index 600157ae33d..317168e9d14 100644 --- a/rand_distr/Cargo.toml +++ b/rand_distr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rand_distr" -version = "0.4.0" +version = "0.4.1" authors = ["The Rand Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/rand_distr/README.md b/rand_distr/README.md index 70dec87ca80..3fc2ea62ef9 100644 --- a/rand_distr/README.md +++ b/rand_distr/README.md @@ -24,7 +24,7 @@ contrast, this `rand_distr` crate focuses on sampling from distributions. The floating point functions from `num_traits` and `libm` are used to support `no_std` environments and ensure reproducibility. If the floating point -functions from `std` are prefered, which may provide better accuracy and +functions from `std` are preferred, which may provide better accuracy and performance but may produce different random values, the `std_math` feature can be enabled. diff --git a/rand_distr/src/binomial.rs b/rand_distr/src/binomial.rs index f3c45953341..5efe367e126 100644 --- a/rand_distr/src/binomial.rs +++ b/rand_distr/src/binomial.rs @@ -106,7 +106,7 @@ impl Distribution for Binomial { // random variate generation. Commun. ACM 31, 2 (February 1988), // 216-222. http://dx.doi.org/10.1145/42372.42381 - // Threshold for prefering the BINV algorithm. The paper suggests 10, + // Threshold for preferring the BINV algorithm. The paper suggests 10, // Ranlib uses 30, and GSL uses 14. const BINV_THRESHOLD: f64 = 10.; @@ -243,7 +243,7 @@ impl Distribution for Binomial { } } - // Step 5.2: Squeezing. Check the value of ln(v) againts upper and + // Step 5.2: Squeezing. Check the value of ln(v) against upper and // lower bound of ln(f(y)). let k = k as f64; let rho = (k / npq) * ((k * (k / 3. + 0.625) + 1. / 6.) / npq + 0.5); diff --git a/rand_distr/src/hypergeometric.rs b/rand_distr/src/hypergeometric.rs index 801dff4e960..8ab2dca0333 100644 --- a/rand_distr/src/hypergeometric.rs +++ b/rand_distr/src/hypergeometric.rs @@ -30,7 +30,7 @@ enum SamplingMethod { /// `f(k) = binomial(K, k) * binomial(N-K, n-k) / binomial(N, n)`, /// where `binomial(a, b) = a! / (b! * (a - b)!)`. /// -/// The [binomial distribution](crate::Binomial) is the analagous distribution +/// The [binomial distribution](crate::Binomial) is the analogous distribution /// for sampling with replacement. It is a good approximation when the population /// size is much larger than the sample size. /// diff --git a/rand_distr/src/poisson.rs b/rand_distr/src/poisson.rs index abc00289445..dc355258dfe 100644 --- a/rand_distr/src/poisson.rs +++ b/rand_distr/src/poisson.rs @@ -110,7 +110,7 @@ where F: Float + FloatConst, Standard: Distribution loop { // draw from the Cauchy distribution comp_dev = rng.sample(cauchy); - // shift the peak of the comparison ditribution + // shift the peak of the comparison distribution result = self.sqrt_2lambda * comp_dev + self.lambda; // repeat the drawing until we are in the range of possible values if result >= F::zero() { diff --git a/rand_distr/src/utils.rs b/rand_distr/src/utils.rs index 878faf2072b..f097bb45780 100644 --- a/rand_distr/src/utils.rs +++ b/rand_distr/src/utils.rs @@ -91,14 +91,14 @@ where let i = bits as usize & 0xff; let u = if symmetric { - // Convert to a value in the range [2,4) and substract to get [-1,1) + // Convert to a value in the range [2,4) and subtract to get [-1,1) // We can't convert to an open range directly, that would require - // substracting `3.0 - EPSILON`, which is not representable. + // subtracting `3.0 - EPSILON`, which is not representable. // It is possible with an extra step, but an open range does not - // seem neccesary for the ziggurat algorithm anyway. + // seem necessary for the ziggurat algorithm anyway. (bits >> 12).into_float_with_exponent(1) - 3.0 } else { - // Convert to a value in the range [1,2) and substract to get (0,1) + // Convert to a value in the range [1,2) and subtract to get (0,1) (bits >> 12).into_float_with_exponent(0) - (1.0 - core::f64::EPSILON / 2.0) }; let x = u * x_tab[i]; diff --git a/rand_hc/CHANGELOG.md b/rand_hc/CHANGELOG.md index ad9fe4dfb40..868679945e0 100644 --- a/rand_hc/CHANGELOG.md +++ b/rand_hc/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.1] - 2021-06-15 +- Adjust crate links + ## [0.3.0] - 2020-12-08 - Bump `rand_core` version to 0.6.0 - Bump MSRV to 1.36 (#1011) diff --git a/rand_hc/Cargo.toml b/rand_hc/Cargo.toml index 403f9f0fb1f..28da55aaeca 100644 --- a/rand_hc/Cargo.toml +++ b/rand_hc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rand_hc" -version = "0.3.0" +version = "0.3.1" authors = ["The Rand Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/rand_hc/src/hc128.rs b/rand_hc/src/hc128.rs index cedd2cb6ba8..c2af7506a08 100644 --- a/rand_hc/src/hc128.rs +++ b/rand_hc/src/hc128.rs @@ -142,7 +142,7 @@ impl BlockRngCore for Hc128Core { let dd = (cc + 16) % 512; let ee = cc.wrapping_sub(16) % 512; // These asserts let the compiler optimize out the bounds checks. - // Some of them may be superflous, and that's fine: + // Some of them may be superfluous, and that's fine: // they'll be optimized out if that's the case. assert!(ee + 15 < 512); assert!(cc + 15 < 512); @@ -238,7 +238,7 @@ impl Hc128Core { let dd = (cc + 16) % 512; let ee = cc.wrapping_sub(16) % 512; // These asserts let the compiler optimize out the bounds checks. - // Some of them may be superflous, and that's fine: + // Some of them may be superfluous, and that's fine: // they'll be optimized out if that's the case. assert!(ee + 15 < 512); assert!(cc + 15 < 512); diff --git a/rand_pcg/CHANGELOG.md b/rand_pcg/CHANGELOG.md index 7c929789e11..7464b301001 100644 --- a/rand_pcg/CHANGELOG.md +++ b/rand_pcg/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.1] - 2021-06-15 +- Add `advance` methods to RNGs (#1111) +- Document dependencies between streams (#1122) + ## [0.3.0] - 2020-12-08 - Bump `rand_core` version to 0.6.0 - Bump MSRV to 1.36 (#1011) diff --git a/rand_pcg/Cargo.toml b/rand_pcg/Cargo.toml index 4a3f90eff94..8ef7a3b5052 100644 --- a/rand_pcg/Cargo.toml +++ b/rand_pcg/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rand_pcg" -version = "0.3.0" +version = "0.3.1" authors = ["The Rand Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/rand_pcg/src/pcg128.rs b/rand_pcg/src/pcg128.rs index f81b7fa8390..0cbb96a42b3 100644 --- a/rand_pcg/src/pcg128.rs +++ b/rand_pcg/src/pcg128.rs @@ -93,7 +93,7 @@ impl Lcg128Xsl64 { #[inline] fn from_state_incr(state: u128, increment: u128) -> Self { let mut pcg = Lcg128Xsl64 { state, increment }; - // Move away from inital value: + // Move away from initial value: pcg.state = pcg.state.wrapping_add(pcg.increment); pcg.step(); pcg diff --git a/rand_pcg/src/pcg64.rs b/rand_pcg/src/pcg64.rs index 602d7bb37fa..5ab945a0f01 100644 --- a/rand_pcg/src/pcg64.rs +++ b/rand_pcg/src/pcg64.rs @@ -94,7 +94,7 @@ impl Lcg64Xsh32 { #[inline] fn from_state_incr(state: u64, increment: u64) -> Self { let mut pcg = Lcg64Xsh32 { state, increment }; - // Move away from inital value: + // Move away from initial value: pcg.state = pcg.state.wrapping_add(pcg.increment); pcg.step(); pcg diff --git a/src/distributions/bernoulli.rs b/src/distributions/bernoulli.rs index d54d5992c48..bf0d5e5eeb9 100644 --- a/src/distributions/bernoulli.rs +++ b/src/distributions/bernoulli.rs @@ -49,7 +49,7 @@ pub struct Bernoulli { // `f64` only has 53 bits of precision, and the next largest value of `p` will // result in `2^64 - 2048`. // -// Also there is a 100% theoretical concern: if someone consistenly wants to +// Also there is a 100% theoretical concern: if someone consistently wants to // generate `true` using the Bernoulli distribution (i.e. by using a probability // of `1.0`), just using `u64::MAX` is not enough. On average it would return // false once every 2^64 iterations. Some people apparently care about this diff --git a/src/distributions/float.rs b/src/distributions/float.rs index 733a40394dd..ce5946f7f01 100644 --- a/src/distributions/float.rs +++ b/src/distributions/float.rs @@ -78,7 +78,7 @@ pub struct Open01; pub trait IntoFloat { type F; - /// Helper method to combine the fraction and a contant exponent into a + /// Helper method to combine the fraction and a constant exponent into a /// float. /// /// Only the least significant bits of `self` may be set, 23 for `f32` and diff --git a/src/distributions/uniform.rs b/src/distributions/uniform.rs index c28760b0953..066ae0df1d0 100644 --- a/src/distributions/uniform.rs +++ b/src/distributions/uniform.rs @@ -158,7 +158,7 @@ use serde::{Serialize, Deserialize}; /// println!("{}", sum); /// ``` /// -/// For a single sample, [`Rng::gen_range`] may be prefered: +/// For a single sample, [`Rng::gen_range`] may be preferred: /// /// ``` /// use rand::Rng; diff --git a/src/rngs/thread.rs b/src/rngs/thread.rs index 552851f1ec3..13511e3ed2a 100644 --- a/src/rngs/thread.rs +++ b/src/rngs/thread.rs @@ -33,7 +33,7 @@ use crate::{CryptoRng, Error, RngCore, SeedableRng}; // Number of generated bytes after which to reseed `ThreadRng`. -// According to benchmarks, reseeding has a noticable impact with thresholds +// According to benchmarks, reseeding has a noticeable impact with thresholds // of 32 kB and less. We choose 64 kB to avoid significant overhead. const THREAD_RNG_RESEED_THRESHOLD: u64 = 1024 * 64; @@ -59,7 +59,7 @@ const THREAD_RNG_RESEED_THRESHOLD: u64 = 1024 * 64; #[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", feature = "std_rng"))))] #[derive(Clone, Debug)] pub struct ThreadRng { - // Rc is explictly !Send and !Sync + // Rc is explicitly !Send and !Sync rng: Rc>>, }