diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3f76c1a..e2e86e38 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index ef92b7f4..4fb165c8 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -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 diff --git a/Cargo.toml b/Cargo.toml index 6f553265..f9cc4350 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,3 @@ exclude = [ "benches", ] resolver = "2" - -[patch.crates-io.rand_core] -git = "https://github.com/rust-random/rand.git" -branch = "master" diff --git a/README.md b/README.md index 8e5baf87..b5b11dad 100644 --- a/README.md +++ b/README.md @@ -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), diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 27a95696..d6bcd302 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -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" diff --git a/rand_hc/CHANGELOG.md b/rand_hc/CHANGELOG.md index 278c1617..5ce40606 100644 --- a/rand_hc/CHANGELOG.md +++ b/rand_hc/CHANGELOG.md @@ -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 diff --git a/rand_hc/Cargo.toml b/rand_hc/Cargo.toml index 6b5420b5..2765459b 100644 --- a/rand_hc/Cargo.toml +++ b/rand_hc/Cargo.toml @@ -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" @@ -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" diff --git a/rand_hc/src/hc128.rs b/rand_hc/src/hc128.rs index 6438ad22..75c00583 100644 --- a/rand_hc/src/hc128.rs +++ b/rand_hc/src/hc128.rs @@ -89,8 +89,6 @@ impl RngCore for Hc128Rng { } } -rand_core::impl_try_crypto_rng_from_crypto_rng!(Hc128Rng); - impl SeedableRng for Hc128Rng { type Seed = ::Seed; @@ -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::::from_rng(rng)) } #[inline] - fn try_from_rng(rng: R) -> Result { + fn try_from_rng(rng: &mut R) -> Result { BlockRng::::try_from_rng(rng).map(Hc128Rng) } } diff --git a/rand_isaac/CHANGELOG.md b/rand_isaac/CHANGELOG.md index f156a218..b0c912f2 100644 --- a/rand_isaac/CHANGELOG.md +++ b/rand_isaac/CHANGELOG.md @@ -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 diff --git a/rand_isaac/Cargo.toml b/rand_isaac/Cargo.toml index 8e5688e0..cc0068d2 100644 --- a/rand_isaac/Cargo.toml +++ b/rand_isaac/Cargo.toml @@ -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" @@ -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 diff --git a/rand_isaac/README.md b/rand_isaac/README.md index 9d2e42eb..7a22ecf9 100644 --- a/rand_isaac/README.md +++ b/rand_isaac/README.md @@ -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. diff --git a/rand_isaac/src/isaac.rs b/rand_isaac/src/isaac.rs index c14b141c..e92ac603 100644 --- a/rand_isaac/src/isaac.rs +++ b/rand_isaac/src/isaac.rs @@ -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)] @@ -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); impl RngCore for IsaacRng { @@ -110,8 +110,6 @@ impl RngCore for IsaacRng { } } -rand_core::impl_try_rng_from_rng_core!(IsaacRng); - impl SeedableRng for IsaacRng { type Seed = ::Seed; @@ -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::::from_rng(rng)) } #[inline] - fn try_from_rng(rng: S) -> Result { + fn try_from_rng(rng: &mut S) -> Result { BlockRng::::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], @@ -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]; @@ -384,7 +382,7 @@ impl SeedableRng for IsaacCore { Self::init(seed, 2) } - fn try_from_rng(mut rng: R) -> Result { + fn try_from_rng(rng: &mut R) -> Result { // Custom `from_rng` implementation that fills a seed with the same size // as the entire state. let mut seed = [w(0u32); RAND_SIZE]; @@ -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); } @@ -533,7 +531,7 @@ mod test { } #[test] - #[cfg(feature = "serde1")] + #[cfg(feature = "serde")] fn test_isaac_serde() { use bincode; use std::io::{BufReader, BufWriter}; diff --git a/rand_isaac/src/isaac64.rs b/rand_isaac/src/isaac64.rs index c3f8dd8b..6b7a5496 100644 --- a/rand_isaac/src/isaac64.rs +++ b/rand_isaac/src/isaac64.rs @@ -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)] @@ -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); impl RngCore for Isaac64Rng { @@ -101,8 +101,6 @@ impl RngCore for Isaac64Rng { } } -rand_core::impl_try_rng_from_rng_core!(Isaac64Rng); - impl SeedableRng for Isaac64Rng { type Seed = ::Seed; @@ -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::::from_rng(rng)) } #[inline] - fn try_from_rng(rng: S) -> Result { + fn try_from_rng(rng: &mut S) -> Result { BlockRng64::::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], @@ -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]; @@ -345,7 +343,7 @@ impl SeedableRng for Isaac64Core { Self::init(seed, 2) } - fn try_from_rng(mut rng: R) -> Result { + fn try_from_rng(rng: &mut R) -> Result { // Custom `from_rng` implementation that fills a seed with the same size // as the entire state. let mut seed = [w(0u64); RAND_SIZE]; @@ -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); } @@ -538,7 +536,7 @@ mod test { } #[test] - #[cfg(feature = "serde1")] + #[cfg(feature = "serde")] fn test_isaac64_serde() { use bincode; use std::io::{BufReader, BufWriter}; diff --git a/rand_isaac/src/lib.rs b/rand_isaac/src/lib.rs index a507b453..1ce08b77 100644 --- a/rand_isaac/src/lib.rs +++ b/rand_isaac/src/lib.rs @@ -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)] diff --git a/rand_jitter/CHANGELOG.md b/rand_jitter/CHANGELOG.md index b72a9b7d..d665ee70 100644 --- a/rand_jitter/CHANGELOG.md +++ b/rand_jitter/CHANGELOG.md @@ -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 diff --git a/rand_jitter/Cargo.toml b/rand_jitter/Cargo.toml index 22c9b83d..8700d3c0 100644 --- a/rand_jitter/Cargo.toml +++ b/rand_jitter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rand_jitter" -version = "0.4.0" +version = "0.5.0" authors = ["The Rand Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" @@ -9,14 +9,14 @@ documentation = "https://docs.rs/rand_jitter" description = "Random number generator based on timing jitter" keywords = ["random", "rng", "os"] edition = "2021" -rust-version = "1.61" +rust-version = "1.63" [features] std = ["rand_core/std"] log = ["dep:log"] [dependencies] -rand_core = { version = "=0.9.0-alpha.1" } +rand_core = { version = "0.9.0" } log = { version = "0.4.4", optional = true } [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] diff --git a/rand_jitter/src/lib.rs b/rand_jitter/src/lib.rs index 77343ba6..3a538962 100644 --- a/rand_jitter/src/lib.rs +++ b/rand_jitter/src/lib.rs @@ -764,26 +764,3 @@ where impls::fill_bytes_via_next(self, dest) } } - -impl rand_core::TryRngCore for JitterRng -where - F: Fn() -> u64 + Send + Sync, -{ - type Error = core::convert::Infallible; - - #[inline] - fn try_next_u32(&mut self) -> Result { - Ok(rand_core::RngCore::next_u32(self)) - } - - #[inline] - fn try_next_u64(&mut self) -> Result { - Ok(rand_core::RngCore::next_u64(self)) - } - - #[inline] - fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), Self::Error> { - rand_core::RngCore::fill_bytes(self, dst); - Ok(()) - } -} diff --git a/rand_xorshift/CHANGELOG.md b/rand_xorshift/CHANGELOG.md index 8716492e..647e4ab5 100644 --- a/rand_xorshift/CHANGELOG.md +++ b/rand_xorshift/CHANGELOG.md @@ -4,7 +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 +## [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) - Document how zero seeds are handled - Correctly document MSRV as 1.36 - Speed up `from_seed` implementation for 128-bit seeds diff --git a/rand_xorshift/Cargo.toml b/rand_xorshift/Cargo.toml index ae26996e..284de4a7 100644 --- a/rand_xorshift/Cargo.toml +++ b/rand_xorshift/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rand_xorshift" -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" @@ -13,13 +13,13 @@ Xorshift random number generator keywords = ["random", "rng", "xorshift"] categories = ["algorithms", "no-std"] edition = "2021" -rust-version = "1.61" +rust-version = "1.63" [features] -serde1 = ["serde"] +serde = ["dep:serde"] [dependencies] -rand_core = { version = "=0.9.0-alpha.1" } +rand_core = { version = "0.9.0" } serde = { version = "1.0.118", default-features = false, features = ["derive"], optional = true } [dev-dependencies] diff --git a/rand_xorshift/README.md b/rand_xorshift/README.md index 2142575c..293ccf15 100644 --- a/rand_xorshift/README.md +++ b/rand_xorshift/README.md @@ -30,7 +30,7 @@ Links: `rand_xorshift` 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. diff --git a/rand_xorshift/src/lib.rs b/rand_xorshift/src/lib.rs index e725db06..89d5ae07 100644 --- a/rand_xorshift/src/lib.rs +++ b/rand_xorshift/src/lib.rs @@ -23,7 +23,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_xorshift/0.3.0" + html_root_url = "https://docs.rs/rand_xorshift/0.4.0" )] #![forbid(unsafe_code)] #![deny(missing_docs)] @@ -33,7 +33,7 @@ use core::fmt; use core::num::Wrapping as w; use rand_core::{impls, le, RngCore, SeedableRng, TryRngCore}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// An Xorshift random number generator. @@ -51,7 +51,7 @@ use serde::{Deserialize, Serialize}; /// ["Xorshift RNGs"](https://www.jstatsoft.org/v08/i14/paper). /// *Journal of Statistical Software*. Vol. 8 (Issue 14). #[derive(Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct XorShiftRng { x: w, y: w, @@ -92,8 +92,6 @@ impl RngCore for XorShiftRng { } } -rand_core::impl_try_rng_from_rng_core!(XorShiftRng); - impl SeedableRng for XorShiftRng { type Seed = [u8; 16]; @@ -116,7 +114,7 @@ impl SeedableRng for XorShiftRng { } } - fn from_rng(mut rng: impl RngCore) -> Self { + fn from_rng(rng: &mut impl RngCore) -> Self { let mut b = [0u8; 16]; loop { rng.fill_bytes(b.as_mut()); @@ -133,7 +131,7 @@ impl SeedableRng for XorShiftRng { } } - fn try_from_rng(mut rng: R) -> Result { + fn try_from_rng(rng: &mut R) -> Result { let mut b = [0u8; 16]; loop { rng.try_fill_bytes(b.as_mut())?; diff --git a/rand_xorshift/tests/mod.rs b/rand_xorshift/tests/mod.rs index 881e982e..8413a26b 100644 --- a/rand_xorshift/tests/mod.rs +++ b/rand_xorshift/tests/mod.rs @@ -77,7 +77,7 @@ fn test_xorshift_clone() { } } -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] #[test] fn test_xorshift_serde() { use bincode; diff --git a/rand_xoshiro/CHANGELOG.md b/rand_xoshiro/CHANGELOG.md index a515d12e..b2a9f2ba 100644 --- a/rand_xoshiro/CHANGELOG.md +++ b/rand_xoshiro/CHANGELOG.md @@ -4,11 +4,13 @@ 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.6.1] - unreleased +## [0.7.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) - Add `Xoshiro128Plus::long_jump` - Add examples for initializing the RNGs - Speed up `from_seed` implementation for 128-bit seeds -- Correctly document MSRV as 1.36 - Fix a few typos in the docs ## [0.6.0] - 2020-12-18 diff --git a/rand_xoshiro/Cargo.toml b/rand_xoshiro/Cargo.toml index 980799a8..f99739f6 100644 --- a/rand_xoshiro/Cargo.toml +++ b/rand_xoshiro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rand_xoshiro" -version = "0.6.0" # NB: When modifying, also modify html_root_url in lib.rs +version = "0.7.0" # NB: When modifying, also modify html_root_url in lib.rs authors = ["The Rand Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" @@ -11,13 +11,13 @@ description = "Xoshiro, xoroshiro and splitmix64 random number generators" keywords = ["random", "rng"] categories = ["algorithms"] edition = "2021" -rust-version = "1.61" +rust-version = "1.63" [features] -serde1 = ["serde"] +serde = ["dep:serde"] [dependencies] -rand_core = { version = "=0.9.0-alpha.1" } +rand_core = { version = "0.9.0" } serde = { version = "1", features = ["derive"], optional=true } [dev-dependencies] diff --git a/rand_xoshiro/README.md b/rand_xoshiro/README.md index e3b792b4..66ac3c49 100644 --- a/rand_xoshiro/README.md +++ b/rand_xoshiro/README.md @@ -21,7 +21,7 @@ Links: `rand_xoshiro` is no_std compatible by default. -The `serde1` feature includes implementations of `Serialize` and `Deserialize` for the included RNGs. +The `serde` feature includes implementations of `Serialize` and `Deserialize` for the included RNGs. ## License diff --git a/rand_xoshiro/src/common.rs b/rand_xoshiro/src/common.rs index e5c63f4f..2fe918bc 100644 --- a/rand_xoshiro/src/common.rs +++ b/rand_xoshiro/src/common.rs @@ -263,6 +263,12 @@ impl Default for Seed512 { } } +impl AsRef<[u8]> for Seed512 { + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + impl AsMut<[u8]> for Seed512 { fn as_mut(&mut self) -> &mut [u8] { &mut self.0 diff --git a/rand_xoshiro/src/lib.rs b/rand_xoshiro/src/lib.rs index 60260536..ebbbeb91 100644 --- a/rand_xoshiro/src/lib.rs +++ b/rand_xoshiro/src/lib.rs @@ -83,7 +83,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_xoshiro/0.6.0" + html_root_url = "https://docs.rs/rand_xoshiro/0.7.0" )] #![forbid(unsafe_code)] #![deny(missing_docs)] diff --git a/rand_xoshiro/src/splitmix64.rs b/rand_xoshiro/src/splitmix64.rs index 88130c74..750b07dd 100644 --- a/rand_xoshiro/src/splitmix64.rs +++ b/rand_xoshiro/src/splitmix64.rs @@ -9,7 +9,7 @@ use rand_core::impls::fill_bytes_via_next; use rand_core::le::read_u64_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A splitmix64 random number generator. @@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize}; /// from [`dsiutils`](http://dsiutils.di.unimi.it/) is used. #[allow(missing_copy_implementations)] #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct SplitMix64 { x: u64, } @@ -59,8 +59,6 @@ impl RngCore for SplitMix64 { } } -rand_core::impl_try_rng_from_rng_core!(SplitMix64); - impl SeedableRng for SplitMix64 { type Seed = [u8; 8]; diff --git a/rand_xoshiro/src/xoroshiro128plus.rs b/rand_xoshiro/src/xoroshiro128plus.rs index 6655d3cc..9ea170ec 100644 --- a/rand_xoshiro/src/xoroshiro128plus.rs +++ b/rand_xoshiro/src/xoroshiro128plus.rs @@ -9,7 +9,7 @@ use rand_core::impls::fill_bytes_via_next; use rand_core::le::read_u64_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoroshiro128+ random number generator. @@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize}; /// David Blackman and Sebastiano Vigna. #[allow(missing_copy_implementations)] #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoroshiro128Plus { s0: u64, s1: u64, @@ -79,9 +79,6 @@ impl RngCore for Xoroshiro128Plus { fill_bytes_via_next(self, dest); } } - -rand_core::impl_try_rng_from_rng_core!(Xoroshiro128Plus); - impl SeedableRng for Xoroshiro128Plus { type Seed = [u8; 16]; diff --git a/rand_xoshiro/src/xoroshiro128plusplus.rs b/rand_xoshiro/src/xoroshiro128plusplus.rs index e90f3291..7fcce84a 100644 --- a/rand_xoshiro/src/xoroshiro128plusplus.rs +++ b/rand_xoshiro/src/xoroshiro128plusplus.rs @@ -9,7 +9,7 @@ use rand_core::impls::fill_bytes_via_next; use rand_core::le::read_u64_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoroshiro128++ random number generator. @@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize}; /// David Blackman and Sebastiano Vigna. #[allow(missing_copy_implementations)] #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoroshiro128PlusPlus { s0: u64, s1: u64, @@ -77,8 +77,6 @@ impl RngCore for Xoroshiro128PlusPlus { } } -rand_core::impl_try_rng_from_rng_core!(Xoroshiro128PlusPlus); - impl SeedableRng for Xoroshiro128PlusPlus { type Seed = [u8; 16]; diff --git a/rand_xoshiro/src/xoroshiro128starstar.rs b/rand_xoshiro/src/xoroshiro128starstar.rs index 8c9e59fe..3f57a639 100644 --- a/rand_xoshiro/src/xoroshiro128starstar.rs +++ b/rand_xoshiro/src/xoroshiro128starstar.rs @@ -9,7 +9,7 @@ use rand_core::impls::fill_bytes_via_next; use rand_core::le::read_u64_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoroshiro128** random number generator. @@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize}; /// David Blackman and Sebastiano Vigna. #[allow(missing_copy_implementations)] #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoroshiro128StarStar { s0: u64, s1: u64, @@ -77,8 +77,6 @@ impl RngCore for Xoroshiro128StarStar { } } -rand_core::impl_try_rng_from_rng_core!(Xoroshiro128StarStar); - impl SeedableRng for Xoroshiro128StarStar { type Seed = [u8; 16]; diff --git a/rand_xoshiro/src/xoroshiro64star.rs b/rand_xoshiro/src/xoroshiro64star.rs index 99411420..0e997e93 100644 --- a/rand_xoshiro/src/xoroshiro64star.rs +++ b/rand_xoshiro/src/xoroshiro64star.rs @@ -9,7 +9,7 @@ use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32}; use rand_core::le::read_u32_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoroshiro64* random number generator. @@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize}; /// David Blackman and Sebastiano Vigna. #[allow(missing_copy_implementations)] #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoroshiro64Star { s0: u32, s1: u32, @@ -48,8 +48,6 @@ impl RngCore for Xoroshiro64Star { } } -rand_core::impl_try_rng_from_rng_core!(Xoroshiro64Star); - impl SeedableRng for Xoroshiro64Star { type Seed = [u8; 8]; diff --git a/rand_xoshiro/src/xoroshiro64starstar.rs b/rand_xoshiro/src/xoroshiro64starstar.rs index 9e47fb41..b9cb45db 100644 --- a/rand_xoshiro/src/xoroshiro64starstar.rs +++ b/rand_xoshiro/src/xoroshiro64starstar.rs @@ -9,7 +9,7 @@ use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32}; use rand_core::le::read_u32_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoroshiro64** random number generator. @@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize}; /// David Blackman and Sebastiano Vigna. #[allow(missing_copy_implementations)] #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoroshiro64StarStar { s0: u32, s1: u32, @@ -47,8 +47,6 @@ impl RngCore for Xoroshiro64StarStar { } } -rand_core::impl_try_rng_from_rng_core!(Xoroshiro64StarStar); - impl SeedableRng for Xoroshiro64StarStar { type Seed = [u8; 8]; diff --git a/rand_xoshiro/src/xoshiro128plus.rs b/rand_xoshiro/src/xoshiro128plus.rs index 50e41617..47f55c52 100644 --- a/rand_xoshiro/src/xoshiro128plus.rs +++ b/rand_xoshiro/src/xoshiro128plus.rs @@ -9,7 +9,7 @@ use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32}; use rand_core::le::read_u32_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoshiro128+ random number generator. @@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize}; /// reference source code](http://xoshiro.di.unimi.it/xoshiro128starstar.c) by /// David Blackman and Sebastiano Vigna. #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoshiro128Plus { s: [u32; 4], } @@ -94,7 +94,7 @@ impl RngCore for Xoshiro128Plus { fill_bytes_via_next(self, dest); } } -rand_core::impl_try_rng_from_rng_core!(Xoshiro128Plus); + #[cfg(test)] mod tests { use super::*; diff --git a/rand_xoshiro/src/xoshiro128plusplus.rs b/rand_xoshiro/src/xoshiro128plusplus.rs index eb222701..d2d8c4a3 100644 --- a/rand_xoshiro/src/xoshiro128plusplus.rs +++ b/rand_xoshiro/src/xoshiro128plusplus.rs @@ -9,7 +9,7 @@ use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32}; use rand_core::le::read_u32_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoshiro128++ random number generator. @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; /// reference source code](http://xoshiro.di.unimi.it/xoshiro128plusplus.c) by /// David Blackman and Sebastiano Vigna. #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoshiro128PlusPlus { s: [u32; 4], } @@ -94,8 +94,6 @@ impl RngCore for Xoshiro128PlusPlus { } } -rand_core::impl_try_rng_from_rng_core!(Xoshiro128PlusPlus); - #[cfg(test)] mod tests { use super::*; diff --git a/rand_xoshiro/src/xoshiro128starstar.rs b/rand_xoshiro/src/xoshiro128starstar.rs index f22d81b4..af7a251c 100644 --- a/rand_xoshiro/src/xoshiro128starstar.rs +++ b/rand_xoshiro/src/xoshiro128starstar.rs @@ -9,7 +9,7 @@ use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32}; use rand_core::le::read_u32_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoshiro128** random number generator. @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; /// reference source code](http://xoshiro.di.unimi.it/xoshiro128starstar.c) by /// David Blackman and Sebastiano Vigna. #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoshiro128StarStar { s: [u32; 4], } @@ -94,8 +94,6 @@ impl RngCore for Xoshiro128StarStar { } } -rand_core::impl_try_rng_from_rng_core!(Xoshiro128StarStar); - #[cfg(test)] mod tests { use super::*; diff --git a/rand_xoshiro/src/xoshiro256plus.rs b/rand_xoshiro/src/xoshiro256plus.rs index 27cd0bca..25ed5ffa 100644 --- a/rand_xoshiro/src/xoshiro256plus.rs +++ b/rand_xoshiro/src/xoshiro256plus.rs @@ -9,7 +9,7 @@ use rand_core::impls::fill_bytes_via_next; use rand_core::le::read_u64_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoshiro256+ random number generator. @@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize}; /// reference source code](http://xoshiro.di.unimi.it/xoshiro256plus.c) by /// David Blackman and Sebastiano Vigna. #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoshiro256Plus { s: [u64; 4], } @@ -115,8 +115,6 @@ impl RngCore for Xoshiro256Plus { } } -rand_core::impl_try_rng_from_rng_core!(Xoshiro256Plus); - #[cfg(test)] mod tests { use super::*; diff --git a/rand_xoshiro/src/xoshiro256plusplus.rs b/rand_xoshiro/src/xoshiro256plusplus.rs index bc30e31c..e27caffc 100644 --- a/rand_xoshiro/src/xoshiro256plusplus.rs +++ b/rand_xoshiro/src/xoshiro256plusplus.rs @@ -9,7 +9,7 @@ use rand_core::impls::fill_bytes_via_next; use rand_core::le::read_u64_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoshiro256++ random number generator. @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; /// reference source code](http://xoshiro.di.unimi.it/xoshiro256plusplus.c) by /// David Blackman and Sebastiano Vigna. #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoshiro256PlusPlus { s: [u64; 4], } @@ -114,8 +114,6 @@ impl RngCore for Xoshiro256PlusPlus { } } -rand_core::impl_try_rng_from_rng_core!(Xoshiro256PlusPlus); - #[cfg(test)] mod tests { use super::*; diff --git a/rand_xoshiro/src/xoshiro256starstar.rs b/rand_xoshiro/src/xoshiro256starstar.rs index fb427977..7bc3beb5 100644 --- a/rand_xoshiro/src/xoshiro256starstar.rs +++ b/rand_xoshiro/src/xoshiro256starstar.rs @@ -9,7 +9,7 @@ use rand_core::impls::fill_bytes_via_next; use rand_core::le::read_u64_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// A xoshiro256** random number generator. @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; /// reference source code](http://xoshiro.di.unimi.it/xoshiro256starstar.c) by /// David Blackman and Sebastiano Vigna. #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoshiro256StarStar { s: [u64; 4], } @@ -114,8 +114,6 @@ impl RngCore for Xoshiro256StarStar { } } -rand_core::impl_try_rng_from_rng_core!(Xoshiro256StarStar); - #[cfg(test)] mod tests { use super::*; diff --git a/rand_xoshiro/src/xoshiro512plus.rs b/rand_xoshiro/src/xoshiro512plus.rs index c3e0a059..974829e3 100644 --- a/rand_xoshiro/src/xoshiro512plus.rs +++ b/rand_xoshiro/src/xoshiro512plus.rs @@ -9,7 +9,7 @@ use rand_core::impls::fill_bytes_via_next; use rand_core::le::read_u64_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::Seed512; @@ -24,7 +24,7 @@ use crate::Seed512; /// reference source code](http://xoshiro.di.unimi.it/xoshiro512plus.c) by /// David Blackman and Sebastiano Vigna. #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoshiro512Plus { s: [u64; 8], } @@ -125,8 +125,6 @@ impl RngCore for Xoshiro512Plus { } } -rand_core::impl_try_rng_from_rng_core!(Xoshiro512Plus); - #[cfg(test)] mod tests { use super::*; diff --git a/rand_xoshiro/src/xoshiro512plusplus.rs b/rand_xoshiro/src/xoshiro512plusplus.rs index f546844a..c9f3c044 100644 --- a/rand_xoshiro/src/xoshiro512plusplus.rs +++ b/rand_xoshiro/src/xoshiro512plusplus.rs @@ -9,7 +9,7 @@ use rand_core::impls::fill_bytes_via_next; use rand_core::le::read_u64_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::Seed512; @@ -23,7 +23,7 @@ use crate::Seed512; /// reference source code](http://xoshiro.di.unimi.it/xoshiro512plusplus.c) by /// David Blackman and Sebastiano Vigna. #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoshiro512PlusPlus { s: [u64; 8], } @@ -124,8 +124,6 @@ impl RngCore for Xoshiro512PlusPlus { } } -rand_core::impl_try_rng_from_rng_core!(Xoshiro512PlusPlus); - #[cfg(test)] mod tests { use super::*; diff --git a/rand_xoshiro/src/xoshiro512starstar.rs b/rand_xoshiro/src/xoshiro512starstar.rs index ac98a0f9..b57fd480 100644 --- a/rand_xoshiro/src/xoshiro512starstar.rs +++ b/rand_xoshiro/src/xoshiro512starstar.rs @@ -9,7 +9,7 @@ use rand_core::impls::fill_bytes_via_next; use rand_core::le::read_u64_into; use rand_core::{RngCore, SeedableRng}; -#[cfg(feature = "serde1")] +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::Seed512; @@ -23,7 +23,7 @@ use crate::Seed512; /// reference source code](http://xoshiro.di.unimi.it/xoshiro512starstar.c) by /// David Blackman and Sebastiano Vigna. #[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Xoshiro512StarStar { s: [u64; 8], } @@ -124,8 +124,6 @@ impl RngCore for Xoshiro512StarStar { } } -rand_core::impl_try_rng_from_rng_core!(Xoshiro512StarStar); - #[cfg(test)] mod tests { use super::*; diff --git a/rand_xoshiro/tests/serde.rs b/rand_xoshiro/tests/serde.rs index 3c49eb43..4bdf19a4 100644 --- a/rand_xoshiro/tests/serde.rs +++ b/rand_xoshiro/tests/serde.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "serde1")] +#![cfg(feature = "serde")] use rand_core::{RngCore, SeedableRng}; use rand_xoshiro::{