Skip to content

Commit 9f05e22

Browse files
authored
Update: getrandom v0.3.0 rc.0 (#1541)
1 parent 88c310b commit 9f05e22

File tree

16 files changed

+43
-70
lines changed

16 files changed

+43
-70
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
run: |
122122
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml
123123
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml --no-default-features
124-
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml --no-default-features --features=alloc,os_rng
124+
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml --no-default-features --features=os_rng
125125
- name: Test rand_distr
126126
run: |
127127
cargo test --target ${{ matrix.target }} --manifest-path rand_distr/Cargo.toml --features=serde

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ 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+
## [0.9.0-beta.1] - 2024-11-30
12+
- Bump `rand_core` version
13+
1114
## [0.9.0-beta.0] - 2024-11-25
1215
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).
1316

@@ -65,6 +68,7 @@ This is a pre-release. To depend on this version, use `rand = "=0.9.0-beta.0"` t
6568
- Distribution `Uniform` implements `TryFrom` instead of `From` for ranges (#1229)
6669
- Optimize distribution `Uniform`: use Canon's method (single sampling) / Lemire's method (distribution sampling) for faster sampling (breaks value stability; #1287)
6770
- Add `UniformUsize` and use to make `Uniform` for `usize` portable (#1487)
71+
- Remove support for generating `isize` and `usize` values with `Standard`, `Uniform` (except via `UniformUsize`) and `Fill` and usage as a `WeightedAliasIndex` weight (#1487)
6872
- Optimize fn `sample_single_inclusive` for floats (+~20% perf) (#1289)
6973
- Allow `UniformFloat::new` samples and `UniformFloat::sample_single` to yield `high` (#1462)
7074
- Add impl `DistString` for distributions `Slice<char>` and `Uniform<char>` (#1315)

Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand"
3-
version = "0.9.0-beta.0"
3+
version = "0.9.0-beta.1"
44
authors = ["The Rand Project Developers", "The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -37,7 +37,7 @@ serde = ["dep:serde", "rand_core/serde"]
3737
std = ["rand_core/std", "rand_chacha?/std", "alloc"]
3838

3939
# Option: "alloc" enables support for Vec and Box when not using "std"
40-
alloc = ["rand_core/alloc"]
40+
alloc = []
4141

4242
# Option: enable OsRng
4343
os_rng = ["rand_core/os_rng"]
@@ -69,14 +69,14 @@ members = [
6969
exclude = ["benches", "distr_test"]
7070

7171
[dependencies]
72-
rand_core = { path = "rand_core", version = "=0.9.0-beta.0", default-features = false }
72+
rand_core = { path = "rand_core", version = "=0.9.0-beta.1", 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-beta.0", default-features = false, optional = true }
75+
rand_chacha = { path = "rand_chacha", version = "=0.9.0-beta.1", 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-beta.0" }
79+
rand_pcg = { path = "rand_pcg", version = "=0.9.0-beta.1" }
8080
# Only to test serde
8181
bincode = "1.2.1"
8282
rayon = "1.7"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ rand = "0.8.5"
6464
Or, to try the 0.9.0 beta release:
6565
```toml
6666
[dependencies]
67-
rand = "=0.9.0-beta.0"
67+
rand = "=0.9.0-beta.1"
6868
```
6969

7070
To get started using Rand, see [The Book](https://rust-random.github.io/book).

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-beta.1", default-features = false, features = ["alloc"] }
9-
rand = { path = "..", version = "=0.9.0-beta.0", features = ["small_rng"] }
8+
rand_distr = { path = "../rand_distr", version = "=0.5.0-beta.2", default-features = false, features = ["alloc"] }
9+
rand = { path = "..", version = "=0.9.0-beta.1", features = ["small_rng"] }
1010
num-traits = "0.2.19"
1111
# Special functions for testing distributions
1212
special = "0.11.0"

rand_chacha/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ 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+
## [0.9.0-beta.1] - 2024-11-30
8+
- Bump `rand_core` version
9+
710
## [0.9.0-beta.0] - 2024-11-25
811
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).
912

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-beta.0"
3+
version = "0.9.0-beta.1"
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-beta.0" }
23+
rand_core = { path = "../rand_core", version = "=0.9.0-beta.1" }
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-beta.0", features = ["os_rng"] }
30+
rand_core = { path = "../rand_core", version = "=0.9.0-beta.1", features = ["os_rng"] }
3131

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

rand_core/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ 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+
## [0.9.0-beta.1] - 2024-11-30
8+
- Update to `getrandom` v0.3.0-rc.0
9+
710
## [0.9.0-beta.0] - 2024-11-25
811
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).
912

rand_core/Cargo.toml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand_core"
3-
version = "0.9.0-beta.0"
3+
version = "0.9.0-beta.1"
44
authors = ["The Rand Project Developers", "The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -25,12 +25,11 @@ rustdoc-args = ["--generate-link-to-definition"]
2525
all-features = true
2626

2727
[features]
28-
std = ["alloc", "getrandom?/std"]
29-
alloc = [] # enables Vec and Box support without std
28+
std = ["getrandom?/std"]
3029
os_rng = ["dep:getrandom"]
3130
serde = ["dep:serde"] # enables serde for BlockRng wrapper
3231

3332
[dependencies]
3433
serde = { version = "1", features = ["derive"], optional = true }
35-
getrandom = { version = "0.2", optional = true }
34+
getrandom = { version = "0.3.0-rc.0", optional = true }
3635
zerocopy = { version = "0.8.0", default-features = false }

rand_core/README.md

+1-26
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,9 @@ The traits and error types are also available via `rand`.
4242

4343
The current version is:
4444
```
45-
rand_core = "0.6.4"
45+
rand_core = "=0.9.0-beta.1"
4646
```
4747

48-
Rand libs have inter-dependencies and make use of the
49-
[semver trick](https://github.com/dtolnay/semver-trick/) in order to make traits
50-
compatible across crate versions. (This is especially important for `RngCore`
51-
and `SeedableRng`.) A few crate releases are thus compatibility shims,
52-
depending on the *next* lib version (e.g. `rand_core` versions `0.2.2` and
53-
`0.3.1`). This means, for example, that `rand_core_0_4_0::SeedableRng` and
54-
`rand_core_0_3_0::SeedableRng` are distinct, incompatible traits, which can
55-
cause build errors. Usually, running `cargo update` is enough to fix any issues.
56-
57-
## Crate Features
58-
59-
`rand_core` supports `no_std` and `alloc`-only configurations, as well as full
60-
`std` functionality. The differences between `no_std` and full `std` are small,
61-
comprising `RngCore` support for `Box<R>` types where `R: RngCore`,
62-
`std::io::Read` support for types supporting `RngCore`, and
63-
extensions to the `Error` type's functionality.
64-
65-
The `std` feature is *not enabled by default*. This is primarily to avoid build
66-
problems where one crate implicitly requires `rand_core` with `std` support and
67-
another crate requires `rand` *without* `std` support. However, the `rand` crate
68-
continues to enable `std` support by default, both for itself and `rand_core`.
69-
70-
The `serde` feature can be used to derive `Serialize` and `Deserialize` for RNG
71-
implementations that use the `BlockRng` or `BlockRng64` wrappers.
72-
7348

7449
# License
7550

rand_core/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3636
#![no_std]
3737

38-
#[cfg(feature = "alloc")]
39-
extern crate alloc;
4038
#[cfg(feature = "std")]
4139
extern crate std;
4240

@@ -512,7 +510,7 @@ pub trait SeedableRng: Sized {
512510
#[cfg(feature = "os_rng")]
513511
fn try_from_os_rng() -> Result<Self, getrandom::Error> {
514512
let mut seed = Self::Seed::default();
515-
getrandom::getrandom(seed.as_mut())?;
513+
getrandom::fill(seed.as_mut())?;
516514
let res = Self::from_seed(seed);
517515
Ok(res)
518516
}

rand_core/src/os.rs

+3-18
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
//! Interface to the random number generator of the operating system.
1010
1111
use crate::{TryCryptoRng, TryRngCore};
12-
use getrandom::getrandom;
1312

1413
/// An interface over the operating-system's random data source
1514
///
@@ -79,38 +78,24 @@ impl OsError {
7978
pub fn raw_os_error(self) -> Option<i32> {
8079
self.0.raw_os_error()
8180
}
82-
83-
/// Extract the bare error code.
84-
///
85-
/// This code can either come from the underlying OS, or be a custom error.
86-
/// Use [`OsError::raw_os_error()`] to disambiguate.
87-
#[inline]
88-
pub const fn code(self) -> core::num::NonZeroU32 {
89-
self.0.code()
90-
}
9181
}
9282

9383
impl TryRngCore for OsRng {
9484
type Error = OsError;
9585

9686
#[inline]
9787
fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
98-
let mut buf = [0u8; 4];
99-
getrandom(&mut buf).map_err(OsError)?;
100-
Ok(u32::from_ne_bytes(buf))
88+
getrandom::u32().map_err(OsError)
10189
}
10290

10391
#[inline]
10492
fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
105-
let mut buf = [0u8; 8];
106-
getrandom(&mut buf).map_err(OsError)?;
107-
Ok(u64::from_ne_bytes(buf))
93+
getrandom::u64().map_err(OsError)
10894
}
10995

11096
#[inline]
11197
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error> {
112-
getrandom(dest).map_err(OsError)?;
113-
Ok(())
98+
getrandom::fill(dest).map_err(OsError)
11499
}
115100
}
116101

rand_distr/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ 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+
## [0.5.0-beta.2] - 2024-11-30
8+
- Bump `rand` version
9+
710
## [0.5.0-beta.1] - 2024-11-27
811
- Fix docs.rs build (#1539)
912

rand_distr/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand_distr"
3-
version = "0.5.0-beta.1"
3+
version = "0.5.0-beta.2"
44
authors = ["The Rand Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -33,15 +33,15 @@ std_math = ["num-traits/std"]
3333
serde = ["dep:serde", "dep:serde_with", "rand/serde"]
3434

3535
[dependencies]
36-
rand = { path = "..", version = "=0.9.0-beta.0", default-features = false }
36+
rand = { path = "..", version = "=0.9.0-beta.1", default-features = false }
3737
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
3838
serde = { version = "1.0.103", features = ["derive"], optional = true }
3939
serde_with = { version = ">= 3.0, <= 3.11", optional = true }
4040

4141
[dev-dependencies]
42-
rand_pcg = { version = "=0.9.0-beta.0", path = "../rand_pcg" }
42+
rand_pcg = { version = "=0.9.0-beta.1", path = "../rand_pcg" }
4343
# For inline examples
44-
rand = { path = "..", version = "=0.9.0-beta.0", features = ["small_rng"] }
44+
rand = { path = "..", version = "=0.9.0-beta.1", features = ["small_rng"] }
4545
# Histogram implementation for testing uniformity
4646
average = { version = "0.15", features = [ "std" ] }
4747
# Special functions for testing distributions

rand_pcg/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ 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+
## [0.9.0-beta.1] - 2024-11-30
8+
- Bump `rand_core` version
9+
710
## [0.9.0-beta.0] - 2024-11-25
811
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).
912

rand_pcg/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rand_pcg"
3-
version = "0.9.0-beta.0"
3+
version = "0.9.0-beta.1"
44
authors = ["The Rand Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"
@@ -24,12 +24,12 @@ serde = ["dep:serde"]
2424
os_rng = ["rand_core/os_rng"]
2525

2626
[dependencies]
27-
rand_core = { path = "../rand_core", version = "=0.9.0-beta.0" }
27+
rand_core = { path = "../rand_core", version = "=0.9.0-beta.1" }
2828
serde = { version = "1", features = ["derive"], optional = true }
2929

3030
[dev-dependencies]
3131
# This is for testing serde, unfortunately we can't specify feature-gated dev
3232
# deps yet, see: https://github.com/rust-lang/cargo/issues/1596
3333
# Versions prior to 1.1.4 had incorrect minimal dependencies.
3434
bincode = { version = "1.1.4" }
35-
rand_core = { path = "../rand_core", version = "=0.9.0-beta.0", features = ["os_rng"] }
35+
rand_core = { path = "../rand_core", version = "=0.9.0-beta.1", features = ["os_rng"] }

0 commit comments

Comments
 (0)