Skip to content
Merged
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
1 change: 1 addition & 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.

## [0.10.0 — Unreleased]
### Changes
- 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)
- Let `Fill` be implemented for element types, not sliceable types (#1652)
Expand Down
11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ serde = ["dep:serde", "rand_core/serde"]

# Option (enabled by default): without "std" rand uses libcore; this option
# enables functionality expected to be available on a standard platform.
std = ["rand_core/std", "rand_chacha?/std", "alloc"]
std = ["rand_core/std", "alloc"]

# Option: "alloc" enables support for Vec and Box when not using "std"
alloc = []
Expand All @@ -46,7 +46,7 @@ os_rng = ["rand_core/os_rng"]
simd_support = []

# Option (enabled by default): enable StdRng
std_rng = ["dep:rand_chacha"]
std_rng = ["dep:chacha20"]

# Option: enable SmallRng
small_rng = []
Expand All @@ -70,11 +70,16 @@ members = [
]
exclude = ["benches", "distr_test"]

# Force chacha20 to use the local rand_code to avoid compiling two different "rand_core"s.
# This is necessary even if the specified versions are the same.
[patch.crates-io]
rand_core = { path = "rand_core" }

[dependencies]
rand_core = { path = "rand_core", version = "0.9.0", default-features = false }
log = { version = "0.4.4", optional = true }
serde = { version = "1.0.103", features = ["derive"], optional = true }
rand_chacha = { path = "rand_chacha", version = "0.9.0", default-features = false, optional = true }
chacha20 = { version = "=0.10.0-rc.2", default-features = false, features = ["rng"], optional = true }

[dev-dependencies]
rand_pcg = { path = "rand_pcg", version = "0.9.0" }
Expand Down
5 changes: 5 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ publish = false
# Option (requires nightly Rust): experimental SIMD support
simd_support = ["rand/simd_support"]

# Force chacha20 to use the local rand_code to avoid compiling two different "rand_core"s.
# This is necessary even if the specified versions are the same.
[patch.crates-io]
rand_core = { path = "../rand_core" }

[dependencies]

[dev-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion examples/rayon-monte-carlo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
//! 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_chacha::{ChaCha8Rng, rand_core::SeedableRng};
use rand_core::SeedableRng;
use rayon::prelude::*;

static SEED: u64 = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/rngs/reseeding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ use rand_core::{CryptoRng, RngCore, SeedableRng, TryCryptoRng, TryRngCore};
/// # Example
///
/// ```
/// use chacha20::ChaCha20Core; // Internal part of ChaChaRng that
/// // implements BlockRngCore
/// use rand::prelude::*;
/// use rand_chacha::ChaCha20Core; // Internal part of ChaChaRng that
/// // implements BlockRngCore
/// use rand::rngs::OsRng;
/// use rand::rngs::ReseedingRng;
///
Expand Down
4 changes: 2 additions & 2 deletions src/rngs/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
use rand_core::{CryptoRng, RngCore, SeedableRng};

#[cfg(any(test, feature = "os_rng"))]
pub(crate) use rand_chacha::ChaCha12Core as Core;
pub(crate) use chacha20::ChaCha12Core as Core;

use rand_chacha::ChaCha12Rng as Rng;
use chacha20::ChaCha12Rng as Rng;

/// A strong, fast (amortized), non-portable RNG
///
Expand Down
Loading