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
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@ jobs:
- name: Maybe nightly
if: ${{ matrix.toolchain == 'nightly' }}
run: |
cargo test --target ${{ matrix.target }} --features=nightly
cargo test --target ${{ matrix.target }}
cargo test --target ${{ matrix.target }} --all-features
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features
- name: Test rand
run: |
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features
cargo build --target ${{ matrix.target }} --no-default-features --features alloc,sys_rng,small_rng,unbiased
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features --features=alloc,sys_rng,small_rng
cargo build --target ${{ matrix.target }} --no-default-features --features alloc,sys_rng,unbiased
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features --features=alloc,sys_rng
cargo test --target ${{ matrix.target }} --examples
- name: Test rand (all stable features)
run: |
cargo test --target ${{ matrix.target }} --features=serde,log,small_rng
cargo test --target ${{ matrix.target }} --features=serde,log
- name: Test rand_pcg
run: cargo test --target ${{ matrix.target }} --manifest-path rand_pcg/Cargo.toml --features=serde

Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
- name: Test
run: |
# all stable features:
cross test --no-fail-fast --target ${{ matrix.target }} --features=serde,log,small_rng
cross test --no-fail-fast --target ${{ matrix.target }} --features=serde,log
cross test --no-fail-fast --target ${{ matrix.target }} --examples
cross test --no-fail-fast --target ${{ matrix.target }} --manifest-path rand_pcg/Cargo.toml --features=serde

Expand All @@ -162,7 +162,7 @@ jobs:
- name: Test rand
run: |
cargo miri test --no-default-features --lib --tests
cargo miri test --features=log,small_rng
cargo miri test --features=log
cargo miri test --manifest-path rand_pcg/Cargo.toml --features=serde

test-no-std:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.

### Removals
- Removed `ReseedingRng` ([#1722])
- Removed unused feature "nightly" ([#1732])
- Removed feature `small_rng` ([#1732])
Copy link
Member

Choose a reason for hiding this comment

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

Mention removed deprecated items.

Copy link
Member Author

Choose a reason for hiding this comment

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

The removal (or rename) was mentioned previously, so I don't see the need.


[#1695]: https://github.com/rust-random/rand/pull/1695
[#1697]: https://github.com/rust-random/rand/pull/1697
[#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

## [0.9.2] - 2025-07-20
### Deprecated
Expand Down
8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ all-features = true
rustdoc-args = ["--generate-link-to-definition"]

[package.metadata.playground]
features = ["small_rng", "serde"]
features = ["serde"]

[features]
# Meta-features:
default = ["std", "std_rng", "sys_rng", "small_rng", "thread_rng"]
nightly = [] # some additions requiring nightly Rust
default = ["std", "std_rng", "sys_rng", "thread_rng"]
serde = ["dep:serde"]

# Option (enabled by default): without "std" rand uses libcore; this option
Expand All @@ -48,9 +47,6 @@ simd_support = []
# Option (enabled by default): enable StdRng
std_rng = ["dep:chacha20"]

# Option: enable SmallRng
small_rng = []

# Option: enable ThreadRng and rng()
thread_rng = ["std", "std_rng", "sys_rng"]

Expand Down
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,22 @@ Rand is built with these features enabled by default:
- `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`
- `small_rng` enables inclusion of the `SmallRng` PRNG

Optionally, the following dependencies can be enabled:

- `log` enables logging via [log](https://crates.io/crates/log)

Additionally, these features configure Rand:

- `nightly` includes some additions requiring nightly Rust
- `simd_support` (experimental) enables sampling of SIMD values
(uniformly random SIMD integers and floats), requiring nightly Rust
- `simd_support` (experimental) enables sampling of SIMD values (uniformly
random SIMD integers and floats). Since `std::simd` is not yet stable this
feature requires nightly Rust and may cause build failures.
- `unbiased` use unbiased sampling for algorithms supporting this option: Uniform distribution.

(By default, bias affecting no more than one in 2^48 samples is accepted.)

Note: enabling this option is expected to affect reproducibility of results.

Note that nightly features are not stable and therefore not all library and
compiler versions will be compatible. This is especially true of Rand's
experimental `simd_support` feature.

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
Expand Down
2 changes: 1 addition & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ simd_support = ["rand/simd_support"]
[dependencies]

[dev-dependencies]
rand = { path = "..", features = ["small_rng", "nightly"] }
rand = { path = ".." }
rand_pcg = { path = "../rand_pcg" }
chacha20 = { version = "0.10.0-rc.10", default-features = false, features = ["rng"] }
criterion = "0.5"
Expand Down
10 changes: 0 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ pub mod seq;
#[cfg(feature = "thread_rng")]
pub use crate::rngs::thread::rng;

/// Access the thread-local generator
///
/// Use [`rand::rng()`](rng()) instead.
#[cfg(feature = "thread_rng")]
#[deprecated(since = "0.9.0", note = "Renamed to `rng`")]
#[inline]
pub fn thread_rng() -> crate::rngs::ThreadRng {
rng()
}

pub use rng::{Fill, RngExt};

#[cfg(feature = "thread_rng")]
Expand Down
1 change: 0 additions & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#[doc(no_inline)]
pub use crate::distr::Distribution;
#[cfg(feature = "small_rng")]
#[doc(no_inline)]
pub use crate::rngs::SmallRng;
#[cfg(feature = "std_rng")]
Expand Down
38 changes: 0 additions & 38 deletions src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,44 +312,6 @@ pub trait RngExt: Rng {
fn fill<T: Fill>(&mut self, dest: &mut [T]) {
Fill::fill_slice(dest, self)
}

/// Alias for [`RngExt::random`].
#[inline]
#[deprecated(
since = "0.9.0",
note = "Renamed to `random` to avoid conflict with the new `gen` keyword in Rust 2024."
)]
fn r#gen<T>(&mut self) -> T
where
StandardUniform: Distribution<T>,
{
self.random()
}

/// Alias for [`RngExt::random_range`].
#[inline]
#[deprecated(since = "0.9.0", note = "Renamed to `random_range`")]
fn gen_range<T, R>(&mut self, range: R) -> T
where
T: SampleUniform,
R: SampleRange<T>,
{
self.random_range(range)
}

/// Alias for [`RngExt::random_bool`].
#[inline]
#[deprecated(since = "0.9.0", note = "Renamed to `random_bool`")]
fn gen_bool(&mut self, p: f64) -> bool {
self.random_bool(p)
}

/// Alias for [`RngExt::random_ratio`].
#[inline]
#[deprecated(since = "0.9.0", note = "Renamed to `random_ratio`")]
fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool {
self.random_ratio(numerator, denominator)
}
}

impl<R: Rng + ?Sized> RngExt for R {}
Expand Down
6 changes: 0 additions & 6 deletions src/rngs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,17 @@
//! [PCG]: https://www.pcg-random.org/
//! [xoshiro]: https://prng.di.unimi.it/

#[cfg(feature = "small_rng")]
mod small;
#[cfg(feature = "small_rng")]
mod xoshiro128plusplus;
#[cfg(feature = "small_rng")]
mod xoshiro256plusplus;

#[cfg(feature = "std_rng")]
mod std;
#[cfg(feature = "thread_rng")]
pub(crate) mod thread;

#[cfg(feature = "small_rng")]
pub use self::small::SmallRng;
#[cfg(feature = "small_rng")]
pub use xoshiro128plusplus::Xoshiro128PlusPlus;
#[cfg(feature = "small_rng")]
pub use xoshiro256plusplus::Xoshiro256PlusPlus;

#[cfg(feature = "std_rng")]
Expand Down
4 changes: 2 additions & 2 deletions src/seq/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ pub trait IteratorRandom: Iterator + Sized {
}

/// Deprecated: use [`Self::sample_fill`] instead
#[deprecated(since = "0.9.2", note = "Renamed to `sample_fill`")]
#[deprecated(since = "0.10.0", note = "Renamed to `sample_fill`")]
fn choose_multiple_fill<R>(self, rng: &mut R, buf: &mut [Self::Item]) -> usize
where
R: Rng + ?Sized,
Expand All @@ -273,7 +273,7 @@ pub trait IteratorRandom: Iterator + Sized {

/// Deprecated: use [`Self::sample`] instead
#[cfg(feature = "alloc")]
#[deprecated(since = "0.9.2", note = "Renamed to `sample`")]
#[deprecated(since = "0.10.0", note = "Renamed to `sample`")]
fn choose_multiple<R>(self, rng: &mut R, amount: usize) -> Vec<Self::Item>
where
R: Rng + ?Sized,
Expand Down
8 changes: 4 additions & 4 deletions src/seq/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pub trait IndexedRandom: Index<usize> {

/// Deprecated: use [`Self::sample`] instead
#[cfg(feature = "alloc")]
#[deprecated(since = "0.9.2", note = "Renamed to `sample`")]
#[deprecated(since = "0.10.0", note = "Renamed to `sample`")]
fn choose_multiple<R>(
&self,
rng: &mut R,
Expand All @@ -293,7 +293,7 @@ pub trait IndexedRandom: Index<usize> {
}

/// Deprecated: use [`Self::sample_array`] instead
#[deprecated(since = "0.9.2", note = "Renamed to `sample_array`")]
#[deprecated(since = "0.10.0", note = "Renamed to `sample_array`")]
fn choose_multiple_array<R, const N: usize>(&self, rng: &mut R) -> Option<[Self::Output; N]>
where
Self::Output: Clone + Sized,
Expand All @@ -304,7 +304,7 @@ pub trait IndexedRandom: Index<usize> {

/// Deprecated: use [`Self::sample_weighted`] instead
#[cfg(feature = "std")]
#[deprecated(since = "0.9.2", note = "Renamed to `sample_weighted`")]
#[deprecated(since = "0.10.0", note = "Renamed to `sample_weighted`")]
fn choose_multiple_weighted<R, F, X>(
&self,
rng: &mut R,
Expand Down Expand Up @@ -536,7 +536,7 @@ impl<'a, S: Index<usize, Output = T> + ?Sized + 'a, T: 'a> ExactSizeIterator

/// Deprecated: renamed to [`IndexedSamples`]
#[cfg(feature = "alloc")]
#[deprecated(since = "0.9.2", note = "Renamed to `IndexedSamples`")]
#[deprecated(since = "0.10.0", note = "Renamed to `IndexedSamples`")]
pub type SliceChooseIter<'a, S, T> = IndexedSamples<'a, S, T>;

#[cfg(test)]
Expand Down