From b2c891ec815d8958350156e6bc3fcef71a52fed8 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Wed, 4 Feb 2026 09:03:39 +0000 Subject: [PATCH 1/4] README: update rng crate list --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fc539b46eb..6de71c2127 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Rand is a set of crates supporting (pseudo-)random generators: - Built over a standard RNG trait: [`rand_core::RngCore`](https://docs.rs/rand_core/latest/rand_core/trait.RngCore.html) - With fast implementations of both [strong](https://rust-random.github.io/book/guide-rngs.html#cryptographically-secure-pseudo-random-number-generators-csprngs) and - [small](https://rust-random.github.io/book/guide-rngs.html#basic-pseudo-random-number-generators-prngs) generators: [`rand::rngs`](https://docs.rs/rand/latest/rand/rngs/index.html), and more RNGs: [`rand_chacha`](https://docs.rs/rand_chacha), [`rand_xoshiro`](https://docs.rs/rand_xoshiro/), [`rand_pcg`](https://docs.rs/rand_pcg/), [rngs repo](https://github.com/rust-random/rngs/) + [small](https://rust-random.github.io/book/guide-rngs.html#basic-pseudo-random-number-generators-prngs) generators: [`rand::rngs`](https://docs.rs/rand/latest/rand/rngs/index.html), and more RNGs: [`chacha20`](https://docs.rs/chacha20), [`rand_xoshiro`](https://docs.rs/rand_xoshiro/), [`rand_pcg`](https://docs.rs/rand_pcg/), [`rand_sfc`](https://docs.rs/rand_sfc/), [`rand_seeder`](https://docs.rs/rand_seeder/), [rngs repo](https://github.com/rust-random/rngs/) - [`rand::rng`](https://docs.rs/rand/latest/rand/fn.rng.html) is an asymptotically-fast, automatically-seeded and reasonably strong generator available on all `std` targets - Direct support for seeding generators from the [getrandom] crate From eef1b4279dffd5347765a96a7dc7e03d25bab919 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Wed, 4 Feb 2026 11:03:53 +0000 Subject: [PATCH 2/4] Reduce which features are enabled by default --- Cargo.lock | 1 + Cargo.toml | 5 +++-- examples/rayon-monte-carlo.rs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f186117dbe..1b3078fdbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -241,6 +241,7 @@ dependencies = [ "getrandom", "log", "postcard", + "rand", "rand_core", "rand_pcg", "rayon", diff --git a/Cargo.toml b/Cargo.toml index 490c6c7191..566e22b91b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,11 +24,11 @@ all-features = true rustdoc-args = ["--generate-link-to-definition"] [package.metadata.playground] -features = ["serde"] +features = ["serde", "std_rng", "sys_rng", "thread_rng"] [features] # Meta-features: -default = ["std", "std_rng", "sys_rng", "thread_rng"] +default = ["std"] serde = ["dep:serde"] # Option (enabled by default): without "std" rand uses libcore; this option @@ -75,6 +75,7 @@ chacha20 = { version = "0.10.0-rc.10", default-features = false, features = ["rn getrandom = { version = "0.4.0-rc.1", optional = true } [dev-dependencies] +rand = { path = ".", features = ["chacha", "thread_rng"] } rand_pcg = { path = "rand_pcg", version = "0.10.0-rc.9" } # Only to test serde postcard = {version = "1.1.3", default-features = false, features = ["alloc"]} diff --git a/examples/rayon-monte-carlo.rs b/examples/rayon-monte-carlo.rs index f1d1ba47a1..50e726912b 100644 --- a/examples/rayon-monte-carlo.rs +++ b/examples/rayon-monte-carlo.rs @@ -38,8 +38,8 @@ //! over BATCH_SIZE trials. Manually batching also turns out to be faster //! for the nondeterministic version of this program as well. -use chacha20::ChaCha8Rng; use rand::distr::{Distribution, Uniform}; +use rand::rngs::ChaCha8Rng; use rand_core::SeedableRng; use rayon::prelude::*; From d40cb891a1e5703b8967f6f064417bcb1bcac762 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Wed, 4 Feb 2026 11:21:07 +0000 Subject: [PATCH 3/4] README updates: features, reprod --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6de71c2127..6c830e490c 100644 --- a/README.md +++ b/README.md @@ -64,13 +64,16 @@ See the [CHANGELOG](https://github.com/rust-random/rand/blob/master/CHANGELOG.md Rand is built with these features enabled by default: - `std` enables functionality dependent on the `std` lib -- `alloc` (implied by `std`) enables functionality requiring an allocator -- `sys_rng` (implied by `std`) enables `rngs::SysRng`, using the [getrandom] crate -- `std_rng` enables inclusion of `StdRng`, `ThreadRng` +- `alloc` (implied by `std`) enables functionality requiring an allocator; a + significant portion of sequence and distribution functionality requires this Optionally, the following dependencies can be enabled: -- `log` enables logging via [log](https://crates.io/crates/log) +- `sys_rng` enables `rand::rngs::SysRng` (uses the [getrandom] crate) +- `std_rng` enables `rand::rngs::StdRng` (uses the [chacha20] crate) +- `chacha` enables `rand::rngs::{ChaCha8Rng, ChaCha12Rng, ChaCha20Rng}` (uses the [chacha20] crate) +- `thread_rng` (implies `std`, `std_rng`, `sys_rng`) enables `rand::rngs::ThreadRng` and `rand::rng()` +- `log` enables logging (uses the [log] crate) Additionally, these features configure Rand: @@ -83,11 +86,6 @@ Additionally, these features configure Rand: Note: enabling this option is expected to affect reproducibility of results. -Rand supports limited functionality in `no_std` mode (enabled via -`default-features = false`). In this case, `SysRng` is -unavailable (unless `sys_rng` is enabled), large parts of `seq` are -unavailable (unless `alloc` is enabled), and `ThreadRng` is unavailable. - ## Portability ### Reproducibility @@ -111,3 +109,5 @@ See [LICENSE-APACHE](https://github.com/rust-random/rand/blob/master/LICENSE-APA [COPYRIGHT](https://github.com/rust-random/rand/blob/master/COPYRIGHT) for details. [getrandom]: https://crates.io/crates/getrandom +[chacha20]: https://crates.io/crates/chacha20 +[log]: https://crates.io/crates/log From 3c9a37a30300f43c5a64dcb41b373b09b87a1287 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Wed, 4 Feb 2026 11:45:04 +0000 Subject: [PATCH 4/4] CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d9bc5854e..56782a20f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update. ## [Unreleased] ### Changes +- The features `std_rng`, `sys_rng` and `thread_rng` are now disabled by default ([#1733]). - The dependency on `rand_chacha` has been replaced with a dependency on `chacha20`. This changes the implementation behind `StdRng`, but the output remains the same. There may be some API breakage when using the ChaCha-types directly as these are now the ones in `chacha20` instead of `rand_chacha` (#1642). - Rename fns `IndexedRandom::choose_multiple` -> `sample`, `choose_multiple_array` -> `sample_array`, `choose_multiple_weighted` -> `sample_weighted`, struct `SliceChooseIter` -> `IndexedSamples` and fns `IteratorRandom::choose_multiple` -> `sample`, `choose_multiple_fill` -> `sample_fill` (#1632) - Use Edition 2024 and MSRV 1.85 (#1653) @@ -38,6 +39,7 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update. [#1717]: https://github.com/rust-random/rand/pull/1717 [#1722]: https://github.com/rust-random/rand/pull/1722 [#1732]: https://github.com/rust-random/rand/pull/1732 +[#1733]: https://github.com/rust-random/rand/pull/1733 ## [0.9.2] - 2025-07-20 ### Deprecated