Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"] }
Comment on lines 77 to +78
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be slightly problematic; e.g. we have CI tests like this which will now use additional features:

cargo test --target ${{ matrix.target }} --lib --tests --no-default-features

But, is there a better alternative? It's nice if examples just work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(BTW "chacha" is not strictly required.)

Copy link
Member

@newpavlov newpavlov Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually I just gate tests on features instead of forcibly enabling them like that.

With chacha tests you also could add chacha20 as a dev dependency.

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"]}
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:

Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion examples/rayon-monte-carlo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down
Loading