Skip to content

Commit 3fac49f

Browse files
authored
Prepare 0.9.0-beta.0 (#1535)
- Update version numbers - Update CHANGELOGs - Add an extra benchmark
1 parent bf9d429 commit 3fac49f

File tree

15 files changed

+177
-130
lines changed

15 files changed

+177
-130
lines changed

CHANGELOG.md

+62-55
Original file line numberDiff line numberDiff line change
@@ -8,79 +8,86 @@ A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md).
88

99
You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful.
1010

11-
## [Unreleased]
12-
- Add `rand::distributions::WeightedIndex::{weight, weights, total_weight}` (#1420)
13-
- Add `IndexedRandom::choose_multiple_array`, `index::sample_array` (#1453, #1469)
14-
- Bump the MSRV to 1.63.0
15-
- Rename `Rng::gen` to `Rng::random` to avoid conflict with the new `gen` keyword in Rust 2024 (#1435)
16-
- Move all benchmarks to new `benches` crate (#1439) and migrate to Criterion (#1490)
17-
- Annotate panicking methods with `#[track_caller]` (#1442, #1447)
18-
- Enable feature `small_rng` by default (#1455)
19-
- Allow `UniformFloat::new` samples and `UniformFloat::sample_single` to yield `high` (#1462)
20-
- Fix portability of `rand::distributions::Slice` (#1469)
21-
- Rename `rand::distributions` to `rand::distr` (#1470)
22-
- The `serde1` feature has been renamed `serde` (#1477)
23-
- The implicit feature `rand_chacha` has been removed. This is enabled by `std_rng`. (#1473)
24-
- Mark `WeightError` as `#[non_exhaustive]` (#1480).
25-
- Add `p()` for `Bernoulli` to access probability (#1481)
26-
- Add `UniformUsize` and use to make `Uniform` for `usize` portable (#1487)
27-
- Require `Clone` and `AsRef` bound for `SeedableRng::Seed`. (#1491)
28-
- Improve SmallRng initialization performance (#1482)
29-
- Rename `Rng::gen_iter` to `random_iter` (#1500)
30-
- Rename `rand::thread_rng()` to `rand::rng()`, and remove from the prelude (#1506)
31-
- Remove `rand::random()` from the prelude (#1506)
32-
- Rename `Rng::gen_range` to `random_range`, `gen_bool` to `random_bool`, `gen_ratio` to `random_ratio` (#1505)
33-
- Rename `Standard` to `StandardUniform` (#1526)
34-
- Remove impl of `Distribution<Option<T>>` for `Standard` (#1526)
35-
- Remove `SmallRng::from_thread_rng` (#1532)
36-
- Remove first parameter (`rng`) of `ReseedingRng::new` (#1533)
37-
- Rename feature `getrandom` to `os_rng`
11+
## [0.9.0-beta.0] - 2024-11-25
12+
This is a pre-release. To depend on this version, use `rand = "=0.9.0-beta.0"` to prevent automatic updates (which can be expected to include breaking changes).
3813

39-
## [0.9.0-alpha.1] - 2024-03-18
40-
- Add the `Slice::num_choices` method to the Slice distribution (#1402)
14+
### Security and unsafe
15+
- Policy: "rand is not a crypto library" (#1514)
16+
- Remove fork-protection from `ReseedingRng` and `ThreadRng`. Instead, it is recommended to call `ThreadRng::reseed` on fork. (#1379)
17+
- Use `zerocopy` to replace some `unsafe` code (#1349, #1393, #1446, #1502)
4118

42-
### Generators
43-
- `ReseedingRng::reseed` also resets the random data cache.
44-
- Remove fork-protection from `ReseedingRng` and `ThreadRng`. Instead, it is recommended to call `ThreadRng::reseed` on fork.
45-
46-
## [0.9.0-alpha.0] - 2024-02-18
47-
This is a pre-release. To depend on this version, use `rand = "=0.9.0-alpha.0"` to prevent automatic updates (which can be expected to include breaking changes).
19+
### Compilation options
20+
- 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`
21+
- Support `std` feature without `getrandom` or `rand_chacha` (#1354)
22+
- Improve `thread_rng` related docs (#1257)
23+
- The `serde1` feature has been renamed `serde` (#1477)
24+
- The implicit feature `rand_chacha` has been removed. This is enabled by `std_rng`. (#1473)
25+
- Enable feature `small_rng` by default (#1455)
26+
- Rename feature `getrandom` to `os_rng` (#1537)
27+
28+
### Inherited changes from `rand_core`
29+
- Add fn `RngCore::read_adapter` implementing `std::io::Read` (#1267)
30+
- Add trait `CryptoBlockRng: BlockRngCore`; make `trait CryptoRng: RngCore` (#1273)
31+
- Add traits `TryRngCore`, `TryCryptoRng` (#1424, #1499)
32+
- Add bounds `Clone` and `AsRef` to associated type `SeedableRng::Seed` (#1491)
33+
34+
### Rng trait and top-level fns
35+
- Rename fn `rand::thread_rng()` to `rand::rng()`, and remove from the prelude (#1506)
36+
- Add top-level fns `random_iter`, `random_range`, `random_bool`, `random_ratio`, `fill` (#1488)
37+
- Remove fn `rand::random()` from the prelude (#1506)
38+
- Re-introduce fn `Rng::gen_iter` as `random_iter` (#1305, #1500)
39+
- Rename fn `Rng::gen` to `random` to avoid conflict with the new `gen` keyword in Rust 2024 (#1438)
40+
- Rename fns `Rng::gen_range` to `random_range`, `gen_bool` to `random_bool`, `gen_ratio` to `random_ratio` (#1505)
41+
- Annotate panicking methods with `#[track_caller]` (#1442, #1447)
4842

49-
### Generators
50-
- Change `SmallRng::seed_from_u64` implementation (#1203)
51-
- Replace `SeedableRng` impl for `SmallRng` with inherent methods, excluding `fn from_seed` (#1368)
43+
### RNGs
44+
- Make `ReseedingRng::reseed` discard remaining data from the last block generated (#1379)
45+
- Change fn `SmallRng::seed_from_u64` implementation (#1203)
46+
- Fix `<SmallRng as SeedableRng>::Seed` size to 256 bits (#1455)
47+
- Remove first parameter (`rng`) of `ReseedingRng::new` (#1533)
48+
- Improve SmallRng initialization performance (#1482)
5249

5350
### Sequences
54-
- Simpler and faster implementation of Floyd's F2 (#1277). This
55-
changes some outputs from `rand::seq::index::sample` and
56-
`rand::seq::SliceRandom::choose_multiple`.
51+
- Optimize fn `sample_floyd`, affecting output of `rand::seq::index::sample` and `rand::seq::SliceRandom::choose_multiple` (#1277)
5752
- New, faster algorithms for `IteratorRandom::choose` and `choose_stable` (#1268)
5853
- New, faster algorithms for `SliceRandom::shuffle` and `partial_shuffle` (#1272)
59-
- Re-introduce `Rng::gen_iter` (#1305)
6054
- Split trait `SliceRandom` into `IndexedRandom`, `IndexedMutRandom`, `SliceRandom` (#1382)
55+
- Add `IndexedRandom::choose_multiple_array`, `index::sample_array` (#1453, #1469)
56+
- Fix `IndexdRandom::choose_multiple_weighted` for very small seeds and optimize for large input length / low memory (#1530)
6157

6258
### Distributions
63-
- `{Uniform, UniformSampler}::{new, new_inclusive}` return a `Result` (instead of potentially panicking) (#1229)
64-
- `Uniform` implements `TryFrom` instead of `From` for ranges (#1229)
65-
- `Uniform` now uses Canon's method (single sampling) / Lemire's method (distribution sampling) for faster sampling (breaks value stability; #1287)
59+
- Rename module `rand::distributions` to `rand::distr` (#1470)
6660
- Relax `Sized` bound on `Distribution<T> for &D` (#1278)
67-
- Explicit impl of `sample_single_inclusive` (+~20% perf) (#1289)
68-
- Impl `DistString` for `Slice<char>` and `Uniform<char>` (#1315)
69-
- Let `Standard` support all `NonZero*` types (#1332)
70-
- Add `trait Weight`, allowing `WeightedIndex` to trap overflow (#1353)
71-
- Rename `WeightedError` to `WeightError`, revising variants (#1382)
61+
- Rename distribution `Standard` to `StandardUniform` (#1526)
62+
- Remove impl of `Distribution<Option<T>>` for `StandardUniform` (#1526)
63+
- Let distribution `StandardUniform` support all `NonZero*` types (#1332)
64+
- Fns `{Uniform, UniformSampler}::{new, new_inclusive}` return a `Result` (instead of potentially panicking) (#1229)
65+
- Distribution `Uniform` implements `TryFrom` instead of `From` for ranges (#1229)
66+
- Optimize distribution `Uniform`: use Canon's method (single sampling) / Lemire's method (distribution sampling) for faster sampling (breaks value stability; #1287)
67+
- Add `UniformUsize` and use to make `Uniform` for `usize` portable (#1487)
68+
- Optimize fn `sample_single_inclusive` for floats (+~20% perf) (#1289)
69+
- Allow `UniformFloat::new` samples and `UniformFloat::sample_single` to yield `high` (#1462)
70+
- Add impl `DistString` for distributions `Slice<char>` and `Uniform<char>` (#1315)
71+
- Add fn `Slice::num_choices` (#1402)
72+
- Fix portability of distribution `Slice` (#1469)
73+
- Add trait `Weight`, allowing `WeightedIndex` to trap overflow (#1353)
74+
- Add fns `weight, weights, total_weight` to distribution `WeightedIndex` (#1420)
75+
- Rename enum `WeightedError` to `WeightError`, revising variants (#1382) and mark as `#[non_exhaustive]` (#1480)
76+
- Add fn `p()` for distribution `Bernoulli` to access probability (#1481)
7277

7378
### SIMD
7479
- Switch to `std::simd`, expand SIMD & docs (#1239)
7580
- Optimise SIMD widening multiply (#1247)
7681

77-
### Other
78-
- Bump MSRV to 1.60.0 (#1207, #1246, #1269, #1341)
79-
- Improve `thread_rng` related docs (#1257)
82+
### Documentation
8083
- Add `Cargo.lock.msrv` file (#1275)
8184
- Docs: enable experimental `--generate-link-to-definition` feature (#1327)
82-
- Use `zerocopy` to replace some `unsafe` code (#1349)
83-
- Support `std` feature without `getrandom` or `rand_chacha` (#1354)
85+
- Better doc of crate features, use `doc_auto_cfg` (#1411, #1450)
86+
87+
### Other
88+
- Reformat with `rustfmt` and enforce (#1448)
89+
- Apply Clippy suggestions and enforce (#1448, #1474)
90+
- Move all benchmarks to new `benches` crate (#1329, #1439) and migrate to Criterion (#1490)
8491

8592
## [0.8.5] - 2021-08-20
8693
### Fixes

Cargo.lock.msrv

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand"
3-
version = "0.9.0-alpha.1"
3+
version = "0.9.0-beta.0"
44
authors = ["The Rand Project Developers", "The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -69,14 +69,14 @@ members = [
6969
exclude = ["benches", "distr_test"]
7070

7171
[dependencies]
72-
rand_core = { path = "rand_core", version = "=0.9.0-alpha.1", default-features = false }
72+
rand_core = { path = "rand_core", version = "=0.9.0-beta.0", default-features = false }
7373
log = { version = "0.4.4", optional = true }
7474
serde = { version = "1.0.103", features = ["derive"], optional = true }
75-
rand_chacha = { path = "rand_chacha", version = "=0.9.0-alpha.1", default-features = false, optional = true }
75+
rand_chacha = { path = "rand_chacha", version = "=0.9.0-beta.0", default-features = false, optional = true }
7676
zerocopy = { version = "0.8.0", default-features = false, features = ["simd"] }
7777

7878
[dev-dependencies]
79-
rand_pcg = { path = "rand_pcg", version = "=0.9.0-alpha.1" }
79+
rand_pcg = { path = "rand_pcg", version = "=0.9.0-beta.0" }
8080
# Only to test serde
8181
bincode = "1.2.1"
8282
rayon = "1.7"

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,17 @@ Documentation:
5656
## Usage
5757

5858
Add this to your `Cargo.toml`:
59-
6059
```toml
6160
[dependencies]
6261
rand = "0.8.5"
6362
```
6463

64+
Or, to try the 0.9.0 beta release:
65+
```toml
66+
[dependencies]
67+
rand = "=0.9.0-beta.0"
68+
```
69+
6570
To get started using Rand, see [The Book](https://rust-random.github.io/book).
6671

6772
## Versions

benches/benches/seq_choose.rs

+27
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,33 @@ pub fn bench(c: &mut Criterion) {
5252
});
5353
}
5454

55+
let lens = [(1, 1000), (950, 1000), (10, 100), (90, 100)];
56+
for (amount, len) in lens {
57+
let name = format!("seq_slice_choose_multiple_weighted_{}_of_{}", amount, len);
58+
c.bench_function(name.as_str(), |b| {
59+
let mut rng = Pcg32::from_rng(&mut rand::rng());
60+
let mut buf = [0i32; 1000];
61+
rng.fill(&mut buf);
62+
let x = black_box(&buf[..len]);
63+
64+
let mut results_buf = [0i32; 950];
65+
let y = black_box(&mut results_buf[..amount]);
66+
let amount = black_box(amount);
67+
68+
b.iter(|| {
69+
// Collect full result to prevent unwanted shortcuts getting
70+
// first element (in case sample_indices returns an iterator).
71+
let samples_iter = x
72+
.choose_multiple_weighted(&mut rng, amount, |_| 1.0)
73+
.unwrap();
74+
for (slot, sample) in y.iter_mut().zip(samples_iter) {
75+
*slot = *sample;
76+
}
77+
y[amount - 1]
78+
})
79+
});
80+
}
81+
5582
c.bench_function("seq_iter_choose_multiple_10_of_100", |b| {
5683
let mut rng = Pcg32::from_rng(&mut rand::rng());
5784
let mut buf = [0i32; 100];

distr_test/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ edition = "2021"
55
publish = false
66

77
[dev-dependencies]
8-
rand_distr = { path = "../rand_distr", version = "=0.5.0-alpha.1", default-features = false, features = ["alloc"] }
9-
rand = { path = "..", version = "=0.9.0-alpha.1", features = ["small_rng"] }
8+
rand_distr = { path = "../rand_distr", version = "=0.5.0-beta.0", default-features = false, features = ["alloc"] }
9+
rand = { path = "..", version = "=0.9.0-beta.0", features = ["small_rng"] }
1010
num-traits = "0.2.19"
1111
# Special functions for testing distributions
1212
special = "0.11.0"

rand_chacha/CHANGELOG.md

+5-8
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
8-
- The `serde1` feature has been renamed `serde` (#1477)
9-
- Rename feature `getrandom` to `os_rng`
10-
11-
## [0.9.0-alpha.1] - 2024-03-18
12-
13-
## [0.9.0-alpha.0] - 2024-02-18
14-
This is a pre-release. To depend on this version, use `rand_chacha = "=0.9.0-alpha.0"` to prevent automatic updates (which can be expected to include breaking changes).
7+
## [0.9.0-beta.0] - 2024-11-25
8+
This is a pre-release. To depend on this version, use `rand_chacha = "=0.9.0-beta.0"` to prevent automatic updates (which can be expected to include breaking changes).
159

1610
- Made `rand_chacha` propagate the `std` feature down to `rand_core` (#1153)
1711
- Remove usage of `unsafe` in `fn generate` (#1181) then optimise for AVX2 (~4-7%) (#1192)
12+
- The `serde1` feature has been renamed `serde` (#1477)
13+
- Revise crate docs (#1454)
14+
- Rename feature `getrandom` to `os_rng` (#1537)
1815

1916
## [0.3.1] - 2021-06-09
2017
- add getters corresponding to existing setters: `get_seed`, `get_stream` (#1124)

rand_chacha/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand_chacha"
3-
version = "0.9.0-alpha.1"
3+
version = "0.9.0-beta.0"
44
authors = ["The Rand Project Developers", "The Rust Project Developers", "The CryptoCorrosion Contributors"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -20,14 +20,14 @@ all-features = true
2020
rustdoc-args = ["--generate-link-to-definition"]
2121

2222
[dependencies]
23-
rand_core = { path = "../rand_core", version = "=0.9.0-alpha.1" }
23+
rand_core = { path = "../rand_core", version = "=0.9.0-beta.0" }
2424
ppv-lite86 = { version = "0.2.14", default-features = false, features = ["simd"] }
2525
serde = { version = "1.0", features = ["derive"], optional = true }
2626

2727
[dev-dependencies]
2828
# Only to test serde
2929
serde_json = "1.0"
30-
rand_core = { path = "../rand_core", version = "=0.9.0-alpha.1", features = ["os_rng"] }
30+
rand_core = { path = "../rand_core", version = "=0.9.0-beta.0", features = ["os_rng"] }
3131

3232
[features]
3333
default = ["std"]

rand_core/CHANGELOG.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
8-
- Bump the MSRV to 1.63.0
9-
- The `serde1` feature has been renamed `serde` (#1477)
10-
- Rename feature `getrandom` to `os_rng`
11-
12-
## [0.9.0-alpha.1] - 2024-03-18
7+
## [0.9.0-beta.0] - 2024-11-25
8+
This is a pre-release. To depend on this version, use `rand_core = "=0.9.0-beta.0"` to prevent automatic updates (which can be expected to include breaking changes).
139

14-
## [0.9.0-alpha.0] - 2024-02-18
15-
This is a pre-release. To depend on this version, use `rand_core = "=0.9.0-alpha.0"` to prevent automatic updates (which can be expected to include breaking changes).
10+
### Compilation options and unsafe
11+
- 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`
12+
- The `serde1` feature has been renamed `serde` (#1477)
13+
- Use `zerocopy` to replace some `unsafe` code (#1349, #1393, #1446, #1502)
1614

17-
- Bump MSRV to 1.60.0 (#1207, #1246, #1269, #1341)
15+
### Other
1816
- Allow `rand_core::impls::fill_via_u*_chunks` to mutate source (#1182)
19-
- Add `fn RngCore::read_adapter` implementing `std::io::Read` (#1267)
20-
- Add `trait CryptoBlockRng: BlockRngCore`; make `trait CryptoRng: RngCore` (#1273)
21-
- Use `zerocopy` to replace some `unsafe` code (#1349, #1393)
17+
- Add fn `RngCore::read_adapter` implementing `std::io::Read` (#1267)
18+
- Add trait `CryptoBlockRng: BlockRngCore`; make `trait CryptoRng: RngCore` (#1273)
19+
- Add traits `TryRngCore`, `TryCryptoRng` (#1424, #1499)
20+
- Add bounds `Clone` and `AsRef` to associated type `SeedableRng::Seed` (#1491)
21+
- Rename feature `getrandom` to `os_rng` (#1537)
2222

2323
## [0.6.4] - 2022-09-15
2424
- Fix unsoundness in `<BlockRng64 as RngCore>::next_u32` (#1160)

rand_core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand_core"
3-
version = "0.9.0-alpha.1"
3+
version = "0.9.0-beta.0"
44
authors = ["The Rand Project Developers", "The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"

0 commit comments

Comments
 (0)