Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rand 0.9.0; fixes #58

Merged
merged 12 commits into from
Jan 27, 2025
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
variant: MSRV
toolchain: 1.61.0
toolchain: 1.63.0
- os: ubuntu-latest
deps: sudo apt-get update ; sudo apt install gcc-multilib
target: i686-unknown-linux-gnu
Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,21 @@ on:
pull_request:
paths-ignore:
- README.md
- "benches/**"
push:
branches: master
paths-ignore:
- README.md
- "benches/**"

jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.78.0
components: clippy
- run: cargo clippy --all --all-targets -- -D warnings

rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt
- run: cargo fmt --all -- --check
components: clippy, rustfmt
- name: Clippy
run: cargo clippy --all --all-targets -- -D warnings
- name: Rustfmt
run: cargo fmt --all -- --check
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ exclude = [
"benches",
]
resolver = "2"

[patch.crates-io.rand_core]
git = "https://github.com/rust-random/rand.git"
branch = "master"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Test Status](https://github.com/rust-random/rngs/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rngs/actions)
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.61-lightgray.svg)](https://github.com/rust-random/rngs#rust-version-requirements)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.63-lightgray.svg)](https://github.com/rust-random/rngs#rust-version-requirements)

Extra random number generators provided by the Rust Random project.
The main repository, [rust-random/rand](https://github.com/rust-random/rand),
Expand Down
12 changes: 6 additions & 6 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
name = "benches"
version = "0.1.0"
edition = "2021"
rust-version = "1.61"
rust-version = "1.63"
publish = false

[dev-dependencies]
criterion = "0.5.0"
criterion-cycles-per-byte = "0.6"
rand_core = { version = "=0.9.0-alpha.1", features = ["getrandom"] }
rand_xoshiro = { path = "../rand_xoshiro", version = "0.6" }
rand_isaac = { path = "../rand_isaac", version = "0.3" }
rand_xorshift = { path = "../rand_xorshift", version = "0.3" }
rand_hc = { path = "../rand_hc", version = "0.3" }
rand_core = { version = "0.9.0", features = ["os_rng"] }
rand_xoshiro = { path = "../rand_xoshiro", version = "0.7" }
rand_isaac = { path = "../rand_isaac", version = "0.4" }
rand_xorshift = { path = "../rand_xorshift", version = "0.4" }
rand_hc = { path = "../rand_hc", version = "0.4" }

[[bench]]
name = "mod"
Expand Down
4 changes: 3 additions & 1 deletion rand_hc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.3] - unreleased
## [0.4.0] - 2025-01-27
- Bump the MSRV to 1.63 (#58)
- Update to `rand_core` v0.9.0 (#58)
- Add examples for initializing the RNGs

## [0.3.2] - 2023-04-15
Expand Down
6 changes: 3 additions & 3 deletions rand_hc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rand_hc"
version = "0.3.2"
version = "0.4.0"
authors = ["The Rand Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand All @@ -13,7 +13,7 @@ HC128 random number generator
keywords = ["random", "rng", "hc128"]
categories = ["algorithms", "no-std"]
edition = "2021"
rust-version = "1.61"
rust-version = "1.63"

[dependencies]
rand_core = "=0.9.0-alpha.1"
rand_core = "0.9.0"
6 changes: 2 additions & 4 deletions rand_hc/src/hc128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ impl RngCore for Hc128Rng {
}
}

rand_core::impl_try_crypto_rng_from_crypto_rng!(Hc128Rng);

impl SeedableRng for Hc128Rng {
type Seed = <Hc128Core as SeedableRng>::Seed;

Expand All @@ -100,12 +98,12 @@ impl SeedableRng for Hc128Rng {
}

#[inline]
fn from_rng(rng: impl RngCore) -> Self {
fn from_rng(rng: &mut impl RngCore) -> Self {
Hc128Rng(BlockRng::<Hc128Core>::from_rng(rng))
}

#[inline]
fn try_from_rng<R: TryRngCore>(rng: R) -> Result<Self, R::Error> {
fn try_from_rng<R: TryRngCore>(rng: &mut R) -> Result<Self, R::Error> {
BlockRng::<Hc128Core>::try_from_rng(rng).map(Hc128Rng)
}
}
Expand Down
6 changes: 4 additions & 2 deletions rand_isaac/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.1] - unreleased
- Correctly document MSRV as 1.36
## [0.4.0] - 2025-01-27
- Bump the MSRV to 1.63 (#58)
- Update to `rand_core` v0.9.0 (#58)
- Rename feature `serde1` to `serde` (#58)
- Fix compiler and clippy warnings
- Add examples for initializing the RNGs

Expand Down
12 changes: 5 additions & 7 deletions rand_isaac/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rand_isaac"
version = "0.3.0" # NB: When modifying, also modify html_root_url in lib.rs
version = "0.4.0" # NB: When modifying, also modify html_root_url in lib.rs
authors = ["The Rand Project Developers", "The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand All @@ -13,16 +13,14 @@ ISAAC random number generator
keywords = ["random", "rng", "isaac"]
categories = ["algorithms", "no-std"]
edition = "2021"
rust-version = "1.61"
rust-version = "1.63"

[features]
serde1 = ["serde", "rand_core/serde1"]
serde = ["dep:serde", "rand_core/serde"]

[dependencies]
rand_core = { version = "=0.9.0-alpha.1" }
serde = { version = "1.0.103", features = ["derive"], optional = true }
# Not a direct dependency but required to boost the minimum version:
serde_derive = { version = "1.0.103", optional = true }
rand_core = { version = "0.9.0" }
serde = { version = "1.0.104", features = ["derive"], optional = true }

[dev-dependencies]
# This is for testing serde, unfortunately we can't specify feature-gated dev
Expand Down
2 changes: 1 addition & 1 deletion rand_isaac/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Links:
`rand_isaac` is `no_std` compatible. It does not require any functionality
outside of the `core` lib, thus there are no features to configure.

The `serde1` feature includes implementations of `Serialize` and `Deserialize`
The `serde` feature includes implementations of `Serialize` and `Deserialize`
for the included RNGs.


Expand Down
22 changes: 10 additions & 12 deletions rand_isaac/src/isaac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use core::num::Wrapping as w;
use core::{fmt, slice};
use rand_core::block::{BlockRng, BlockRngCore};
use rand_core::{le, RngCore, SeedableRng, TryRngCore};
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

#[allow(non_camel_case_types)]
Expand Down Expand Up @@ -90,7 +90,7 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
///
/// [`rand_hc`]: https://docs.rs/rand_hc
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct IsaacRng(BlockRng<IsaacCore>);

impl RngCore for IsaacRng {
Expand All @@ -110,8 +110,6 @@ impl RngCore for IsaacRng {
}
}

rand_core::impl_try_rng_from_rng_core!(IsaacRng);

impl SeedableRng for IsaacRng {
type Seed = <IsaacCore as SeedableRng>::Seed;

Expand All @@ -129,22 +127,22 @@ impl SeedableRng for IsaacRng {
}

#[inline]
fn from_rng(rng: impl RngCore) -> Self {
fn from_rng(rng: &mut impl RngCore) -> Self {
IsaacRng(BlockRng::<IsaacCore>::from_rng(rng))
}

#[inline]
fn try_from_rng<S: TryRngCore>(rng: S) -> Result<Self, S::Error> {
fn try_from_rng<S: TryRngCore>(rng: &mut S) -> Result<Self, S::Error> {
BlockRng::<IsaacCore>::try_from_rng(rng).map(IsaacRng)
}
}

/// The core of [`IsaacRng`], used with [`BlockRng`].
#[derive(Clone)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct IsaacCore {
#[cfg_attr(
feature = "serde1",
feature = "serde",
serde(with = "super::isaac_array::isaac_array_serde")
)]
mem: [w32; RAND_SIZE],
Expand Down Expand Up @@ -367,7 +365,7 @@ impl SeedableRng for IsaacCore {
Self::init(key, 1)
}

fn from_rng(mut rng: impl RngCore) -> Self {
fn from_rng(rng: &mut impl RngCore) -> Self {
// Custom `from_rng` implementation that fills a seed with the same size
// as the entire state.
let mut seed = [w(0u32); RAND_SIZE];
Expand All @@ -384,7 +382,7 @@ impl SeedableRng for IsaacCore {
Self::init(seed, 2)
}

fn try_from_rng<R: TryRngCore>(mut rng: R) -> Result<Self, R::Error> {
fn try_from_rng<R: TryRngCore>(rng: &mut R) -> Result<Self, R::Error> {
// Custom `from_rng` implementation that fills a seed with the same size
// as the entire state.
let mut seed = [w(0u32); RAND_SIZE];
Expand Down Expand Up @@ -417,7 +415,7 @@ mod test {
let mut rng1 = IsaacRng::from_seed(seed);
assert_eq!(rng1.next_u32(), 2869442790);

let mut rng2 = IsaacRng::from_rng(rng1);
let mut rng2 = IsaacRng::from_rng(&mut rng1);
assert_eq!(rng2.next_u32(), 3094074039);
}

Expand Down Expand Up @@ -533,7 +531,7 @@ mod test {
}

#[test]
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
fn test_isaac_serde() {
use bincode;
use std::io::{BufReader, BufWriter};
Expand Down
22 changes: 10 additions & 12 deletions rand_isaac/src/isaac64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use core::num::Wrapping as w;
use core::{fmt, slice};
use rand_core::block::{BlockRng64, BlockRngCore};
use rand_core::{le, RngCore, SeedableRng, TryRngCore};
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

#[allow(non_camel_case_types)]
Expand Down Expand Up @@ -81,7 +81,7 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
/// [`rand_hc`]: https://docs.rs/rand_hc
/// [`BlockRng64`]: rand_core::block::BlockRng64
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Isaac64Rng(BlockRng64<Isaac64Core>);

impl RngCore for Isaac64Rng {
Expand All @@ -101,8 +101,6 @@ impl RngCore for Isaac64Rng {
}
}

rand_core::impl_try_rng_from_rng_core!(Isaac64Rng);

impl SeedableRng for Isaac64Rng {
type Seed = <Isaac64Core as SeedableRng>::Seed;

Expand All @@ -120,22 +118,22 @@ impl SeedableRng for Isaac64Rng {
}

#[inline]
fn from_rng(rng: impl RngCore) -> Self {
fn from_rng(rng: &mut impl RngCore) -> Self {
Isaac64Rng(BlockRng64::<Isaac64Core>::from_rng(rng))
}

#[inline]
fn try_from_rng<S: TryRngCore>(rng: S) -> Result<Self, S::Error> {
fn try_from_rng<S: TryRngCore>(rng: &mut S) -> Result<Self, S::Error> {
BlockRng64::<Isaac64Core>::try_from_rng(rng).map(Isaac64Rng)
}
}

/// The core of `Isaac64Rng`, used with `BlockRng`.
#[derive(Clone)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Isaac64Core {
#[cfg_attr(
feature = "serde1",
feature = "serde",
serde(with = "super::isaac_array::isaac_array_serde")
)]
mem: [w64; RAND_SIZE],
Expand Down Expand Up @@ -329,7 +327,7 @@ impl SeedableRng for Isaac64Core {
Self::init(key, 1)
}

fn from_rng(mut rng: impl RngCore) -> Self {
fn from_rng(rng: &mut impl RngCore) -> Self {
// Custom `from_rng` implementation that fills a seed with the same size
// as the entire state.
let mut seed = [w(0u64); RAND_SIZE];
Expand All @@ -345,7 +343,7 @@ impl SeedableRng for Isaac64Core {
Self::init(seed, 2)
}

fn try_from_rng<R: TryRngCore>(mut rng: R) -> Result<Self, R::Error> {
fn try_from_rng<R: TryRngCore>(rng: &mut R) -> Result<Self, R::Error> {
// Custom `from_rng` implementation that fills a seed with the same size
// as the entire state.
let mut seed = [w(0u64); RAND_SIZE];
Expand Down Expand Up @@ -377,7 +375,7 @@ mod test {
let mut rng1 = Isaac64Rng::from_seed(seed);
assert_eq!(rng1.next_u64(), 14964555543728284049);

let mut rng2 = Isaac64Rng::from_rng(rng1);
let mut rng2 = Isaac64Rng::from_rng(&mut rng1);
assert_eq!(rng2.next_u64(), 919595328260451758);
}

Expand Down Expand Up @@ -538,7 +536,7 @@ mod test {
}

#[test]
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
fn test_isaac64_serde() {
use bincode;
use std::io::{BufReader, BufWriter};
Expand Down
2 changes: 1 addition & 1 deletion rand_isaac/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#![doc(
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
html_root_url = "https://docs.rs/rand_isaac/0.3.0"
html_root_url = "https://docs.rs/rand_isaac/0.4.0"
)]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
Expand Down
6 changes: 5 additions & 1 deletion rand_jitter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.0] - 2023-11-20
## [0.5.0] - 2025-01-27
- Bump the MSRV to 1.63 (#58)
- Update to `rand_core` v0.9.0 (#58)

## [0.4.0] - 2023-12-08
### Changed
- Update to `rand_core` v0.6
- Bump MSRV to 1.51
Expand Down
Loading
Loading