diff --git a/Cargo.toml b/Cargo.toml index cec30e72..fcf28930 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,4 +13,4 @@ exclude = [ resolver = "2" [patch.crates-io] -rand_core = { git = "https://github.com/rust-random/rand_core.git", branch = "reduce-block-code" } +rand_core = { git = "https://github.com/rust-random/rand_core.git" } diff --git a/rand_hc/src/hc128.rs b/rand_hc/src/hc128.rs index fe78a8e9..c58f6826 100644 --- a/rand_hc/src/hc128.rs +++ b/rand_hc/src/hc128.rs @@ -16,7 +16,7 @@ use core::fmt; use rand_core::block::{BlockRng, CryptoGenerator, Generator}; -use rand_core::{CryptoRng, RngCore, SeedableRng, le}; +use rand_core::{CryptoRng, RngCore, SeedableRng, utils}; const SEED_WORDS: usize = 8; // 128 bit key followed by 128 bit iv @@ -335,8 +335,7 @@ impl SeedableRng for Hc128Core { /// 256 bits in length, matching the 128 bit `key` followed by 128 bit `iv` /// when HC-128 where to be used as a stream cipher. fn from_seed(seed: Self::Seed) -> Self { - let mut seed_u32 = [0u32; SEED_WORDS]; - le::read_u32_into(&seed, &mut seed_u32); + let seed_u32: [u32; SEED_WORDS] = utils::read_words(&seed); Self::init(seed_u32) } } diff --git a/rand_isaac/src/isaac.rs b/rand_isaac/src/isaac.rs index fe4a79a9..1d90eb45 100644 --- a/rand_isaac/src/isaac.rs +++ b/rand_isaac/src/isaac.rs @@ -12,7 +12,7 @@ use core::num::Wrapping as w; use core::{fmt, slice}; use rand_core::block::{BlockRng, Generator}; -use rand_core::{RngCore, SeedableRng, TryRngCore, le}; +use rand_core::{RngCore, SeedableRng, TryRngCore, utils}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -343,8 +343,7 @@ impl SeedableRng for IsaacCore { type Seed = [u8; 32]; fn from_seed(seed: Self::Seed) -> Self { - let mut seed_u32 = [0u32; 8]; - le::read_u32_into(&seed, &mut seed_u32); + let seed_u32: [u32; 8] = utils::read_words(&seed); // Convert the seed to `Wrapping` and zero-extend to `RAND_SIZE`. let mut seed_extended = [w(0); RAND_SIZE]; for (x, y) in seed_extended.iter_mut().zip(seed_u32.iter()) { diff --git a/rand_isaac/src/isaac64.rs b/rand_isaac/src/isaac64.rs index 174c8e5d..2b2ed012 100644 --- a/rand_isaac/src/isaac64.rs +++ b/rand_isaac/src/isaac64.rs @@ -12,7 +12,7 @@ use core::num::Wrapping as w; use core::{fmt, slice}; use rand_core::block::{BlockRng, Generator}; -use rand_core::{RngCore, SeedableRng, TryRngCore, le}; +use rand_core::{RngCore, SeedableRng, TryRngCore, utils}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -309,8 +309,7 @@ impl SeedableRng for Isaac64Core { type Seed = [u8; 32]; fn from_seed(seed: Self::Seed) -> Self { - let mut seed_u64 = [0u64; 4]; - le::read_u64_into(&seed, &mut seed_u64); + let seed_u64: [u64; 4] = utils::read_words(&seed); // Convert the seed to `Wrapping` and zero-extend to `RAND_SIZE`. let mut seed_extended = [w(0); RAND_SIZE]; for (x, y) in seed_extended.iter_mut().zip(seed_u64.iter()) { diff --git a/rand_jitter/src/lib.rs b/rand_jitter/src/lib.rs index 1e864104..e323878a 100644 --- a/rand_jitter/src/lib.rs +++ b/rand_jitter/src/lib.rs @@ -106,7 +106,7 @@ mod error; mod platform; pub use crate::error::TimerError; -use rand_core::{RngCore, le}; +use rand_core::{RngCore, utils}; use core::{fmt, mem, ptr}; #[cfg(feature = "std")] @@ -760,6 +760,6 @@ where // // This is done especially for wrappers that implement `next_u32` // themselves via `fill_bytes`. - le::fill_bytes_via_next(self, dest) + utils::fill_bytes_via_next_word(dest, || self.next_u64()) } } diff --git a/rand_sfc/src/sfc32.rs b/rand_sfc/src/sfc32.rs index 42e2023e..fc991aec 100644 --- a/rand_sfc/src/sfc32.rs +++ b/rand_sfc/src/sfc32.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, next_u64_via_u32, read_u32_into}; +use rand_core::utils::{fill_bytes_via_next_word, next_u64_via_u32, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] @@ -60,7 +60,7 @@ impl RngCore for Sfc32 { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } @@ -73,8 +73,7 @@ impl SeedableRng for Sfc32 { /// Create a new `Sfc32`. fn from_seed(seed: [u8; 12]) -> Sfc32 { - let mut s = [0; 3]; - read_u32_into(&seed, &mut s); + let s: [u32; 3] = read_words(&seed); let mut rng = Sfc32 { a: s[0], diff --git a/rand_sfc/src/sfc64.rs b/rand_sfc/src/sfc64.rs index e1da7388..709f8854 100644 --- a/rand_sfc/src/sfc64.rs +++ b/rand_sfc/src/sfc64.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] @@ -63,7 +63,7 @@ impl RngCore for Sfc64 { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } @@ -76,8 +76,7 @@ impl SeedableRng for Sfc64 { /// Create a new `Sfc64`. fn from_seed(seed: [u8; 24]) -> Sfc64 { - let mut s = [0; 3]; - read_u64_into(&seed, &mut s); + let s: [u64; 3] = read_words(&seed); let mut rng = Sfc64 { a: s[0], diff --git a/rand_xorshift/src/lib.rs b/rand_xorshift/src/lib.rs index 188d31b8..f57c31af 100644 --- a/rand_xorshift/src/lib.rs +++ b/rand_xorshift/src/lib.rs @@ -31,7 +31,7 @@ use core::fmt; use core::num::Wrapping as w; -use rand_core::{RngCore, SeedableRng, TryRngCore, le}; +use rand_core::{RngCore, SeedableRng, TryRngCore, utils}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -82,12 +82,12 @@ impl RngCore for XorShiftRng { #[inline] fn next_u64(&mut self) -> u64 { - le::next_u64_via_u32(self) + utils::next_u64_via_u32(self) } #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - le::fill_bytes_via_next(self, dest) + utils::fill_bytes_via_next_word(dest, || self.next_u64()) } } @@ -95,8 +95,7 @@ impl SeedableRng for XorShiftRng { type Seed = [u8; 16]; fn from_seed(seed: Self::Seed) -> Self { - let mut seed_u32 = [0u32; 4]; - le::read_u32_into(&seed, &mut seed_u32); + let mut seed_u32: [u32; 4] = utils::read_words(&seed); // Xorshift cannot be seeded with 0 and we cannot return an Error, but // also do not wish to panic (because a random seed can legitimately be diff --git a/rand_xoshiro/src/splitmix64.rs b/rand_xoshiro/src/splitmix64.rs index 535cc32c..ce5da406 100644 --- a/rand_xoshiro/src/splitmix64.rs +++ b/rand_xoshiro/src/splitmix64.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -54,7 +54,7 @@ impl RngCore for SplitMix64 { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } @@ -63,8 +63,7 @@ impl SeedableRng for SplitMix64 { /// Create a new `SplitMix64`. fn from_seed(seed: [u8; 8]) -> SplitMix64 { - let mut state = [0; 1]; - read_u64_into(&seed, &mut state); + let state: [u64; 1] = read_words(&seed); SplitMix64 { x: state[0] } } diff --git a/rand_xoshiro/src/xoroshiro128plus.rs b/rand_xoshiro/src/xoroshiro128plus.rs index dfb927e5..a5c5d29b 100644 --- a/rand_xoshiro/src/xoroshiro128plus.rs +++ b/rand_xoshiro/src/xoroshiro128plus.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -75,7 +75,7 @@ impl RngCore for Xoroshiro128Plus { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } impl SeedableRng for Xoroshiro128Plus { @@ -85,8 +85,7 @@ impl SeedableRng for Xoroshiro128Plus { /// mapped to a different seed. fn from_seed(seed: [u8; 16]) -> Xoroshiro128Plus { deal_with_zero_seed!(seed, Self, 16); - let mut s = [0; 2]; - read_u64_into(&seed, &mut s); + let s: [u64; 2] = read_words(&seed); Xoroshiro128Plus { s0: s[0], s1: s[1] } } diff --git a/rand_xoshiro/src/xoroshiro128plusplus.rs b/rand_xoshiro/src/xoroshiro128plusplus.rs index d10934d8..53bb7878 100644 --- a/rand_xoshiro/src/xoroshiro128plusplus.rs +++ b/rand_xoshiro/src/xoroshiro128plusplus.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -72,7 +72,7 @@ impl RngCore for Xoroshiro128PlusPlus { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } @@ -83,8 +83,7 @@ impl SeedableRng for Xoroshiro128PlusPlus { /// mapped to a different seed. fn from_seed(seed: [u8; 16]) -> Xoroshiro128PlusPlus { deal_with_zero_seed!(seed, Self, 16); - let mut s = [0; 2]; - read_u64_into(&seed, &mut s); + let s: [u64; 2] = read_words(&seed); Xoroshiro128PlusPlus { s0: s[0], s1: s[1] } } diff --git a/rand_xoshiro/src/xoroshiro128starstar.rs b/rand_xoshiro/src/xoroshiro128starstar.rs index 30972f50..583e682c 100644 --- a/rand_xoshiro/src/xoroshiro128starstar.rs +++ b/rand_xoshiro/src/xoroshiro128starstar.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -72,7 +72,7 @@ impl RngCore for Xoroshiro128StarStar { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } @@ -83,8 +83,7 @@ impl SeedableRng for Xoroshiro128StarStar { /// mapped to a different seed. fn from_seed(seed: [u8; 16]) -> Xoroshiro128StarStar { deal_with_zero_seed!(seed, Self, 16); - let mut s = [0; 2]; - read_u64_into(&seed, &mut s); + let s: [u64; 2] = read_words(&seed); Xoroshiro128StarStar { s0: s[0], s1: s[1] } } diff --git a/rand_xoshiro/src/xoroshiro64star.rs b/rand_xoshiro/src/xoroshiro64star.rs index f6e86d86..ba846919 100644 --- a/rand_xoshiro/src/xoroshiro64star.rs +++ b/rand_xoshiro/src/xoroshiro64star.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, next_u64_via_u32, read_u32_into}; +use rand_core::utils::{fill_bytes_via_next_word, next_u64_via_u32, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -43,7 +43,7 @@ impl RngCore for Xoroshiro64Star { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } @@ -54,8 +54,7 @@ impl SeedableRng for Xoroshiro64Star { /// mapped to a different seed. fn from_seed(seed: [u8; 8]) -> Xoroshiro64Star { deal_with_zero_seed!(seed, Self, 8); - let mut s = [0; 2]; - read_u32_into(&seed, &mut s); + let s: [u32; 2] = read_words(&seed); Xoroshiro64Star { s0: s[0], s1: s[1] } } diff --git a/rand_xoshiro/src/xoroshiro64starstar.rs b/rand_xoshiro/src/xoroshiro64starstar.rs index bfce708d..fa46743b 100644 --- a/rand_xoshiro/src/xoroshiro64starstar.rs +++ b/rand_xoshiro/src/xoroshiro64starstar.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, next_u64_via_u32, read_u32_into}; +use rand_core::utils::{fill_bytes_via_next_word, next_u64_via_u32, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -42,7 +42,7 @@ impl RngCore for Xoroshiro64StarStar { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } @@ -53,8 +53,7 @@ impl SeedableRng for Xoroshiro64StarStar { /// mapped to a different seed. fn from_seed(seed: [u8; 8]) -> Xoroshiro64StarStar { deal_with_zero_seed!(seed, Self, 8); - let mut s = [0; 2]; - read_u32_into(&seed, &mut s); + let s: [u32; 2] = read_words(&seed); Xoroshiro64StarStar { s0: s[0], s1: s[1] } } diff --git a/rand_xoshiro/src/xoshiro128plus.rs b/rand_xoshiro/src/xoshiro128plus.rs index b6c53883..aaea53ab 100644 --- a/rand_xoshiro/src/xoshiro128plus.rs +++ b/rand_xoshiro/src/xoshiro128plus.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, next_u64_via_u32, read_u32_into}; +use rand_core::utils::{fill_bytes_via_next_word, next_u64_via_u32, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -64,8 +64,7 @@ impl SeedableRng for Xoshiro128Plus { #[inline] fn from_seed(seed: [u8; 16]) -> Xoshiro128Plus { deal_with_zero_seed!(seed, Self, 16); - let mut state = [0; 4]; - read_u32_into(&seed, &mut state); + let state: [u32; 4] = read_words(&seed); Xoshiro128Plus { s: state } } @@ -90,7 +89,7 @@ impl RngCore for Xoshiro128Plus { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } diff --git a/rand_xoshiro/src/xoshiro128plusplus.rs b/rand_xoshiro/src/xoshiro128plusplus.rs index 793bee75..c8415292 100644 --- a/rand_xoshiro/src/xoshiro128plusplus.rs +++ b/rand_xoshiro/src/xoshiro128plusplus.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, next_u64_via_u32, read_u32_into}; +use rand_core::utils::{fill_bytes_via_next_word, next_u64_via_u32, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -63,8 +63,7 @@ impl SeedableRng for Xoshiro128PlusPlus { #[inline] fn from_seed(seed: [u8; 16]) -> Xoshiro128PlusPlus { deal_with_zero_seed!(seed, Self, 16); - let mut state = [0; 4]; - read_u32_into(&seed, &mut state); + let state: [u32; 4] = read_words(&seed); Xoshiro128PlusPlus { s: state } } @@ -89,7 +88,7 @@ impl RngCore for Xoshiro128PlusPlus { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } diff --git a/rand_xoshiro/src/xoshiro128starstar.rs b/rand_xoshiro/src/xoshiro128starstar.rs index 67b38b34..e6544c18 100644 --- a/rand_xoshiro/src/xoshiro128starstar.rs +++ b/rand_xoshiro/src/xoshiro128starstar.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, next_u64_via_u32, read_u32_into}; +use rand_core::utils::{fill_bytes_via_next_word, next_u64_via_u32, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -63,8 +63,7 @@ impl SeedableRng for Xoshiro128StarStar { #[inline] fn from_seed(seed: [u8; 16]) -> Xoshiro128StarStar { deal_with_zero_seed!(seed, Self, 16); - let mut state = [0; 4]; - read_u32_into(&seed, &mut state); + let state: [u32; 4] = read_words(&seed); Xoshiro128StarStar { s: state } } @@ -89,7 +88,7 @@ impl RngCore for Xoshiro128StarStar { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } diff --git a/rand_xoshiro/src/xoshiro256plus.rs b/rand_xoshiro/src/xoshiro256plus.rs index c1f4b15b..910236db 100644 --- a/rand_xoshiro/src/xoshiro256plus.rs +++ b/rand_xoshiro/src/xoshiro256plus.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -82,8 +82,7 @@ impl SeedableRng for Xoshiro256Plus { #[inline] fn from_seed(seed: [u8; 32]) -> Xoshiro256Plus { deal_with_zero_seed!(seed, Self); - let mut state = [0; 4]; - read_u64_into(&seed, &mut state); + let state: [u64; 4] = read_words(&seed); Xoshiro256Plus { s: state } } @@ -110,7 +109,7 @@ impl RngCore for Xoshiro256Plus { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } diff --git a/rand_xoshiro/src/xoshiro256plusplus.rs b/rand_xoshiro/src/xoshiro256plusplus.rs index ed1aee6c..e56651c3 100644 --- a/rand_xoshiro/src/xoshiro256plusplus.rs +++ b/rand_xoshiro/src/xoshiro256plusplus.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -81,8 +81,7 @@ impl SeedableRng for Xoshiro256PlusPlus { #[inline] fn from_seed(seed: [u8; 32]) -> Xoshiro256PlusPlus { deal_with_zero_seed!(seed, Self); - let mut state = [0; 4]; - read_u64_into(&seed, &mut state); + let state: [u64; 4] = read_words(&seed); Xoshiro256PlusPlus { s: state } } @@ -109,7 +108,7 @@ impl RngCore for Xoshiro256PlusPlus { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } diff --git a/rand_xoshiro/src/xoshiro256starstar.rs b/rand_xoshiro/src/xoshiro256starstar.rs index 650505ab..9df7df6f 100644 --- a/rand_xoshiro/src/xoshiro256starstar.rs +++ b/rand_xoshiro/src/xoshiro256starstar.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -81,8 +81,7 @@ impl SeedableRng for Xoshiro256StarStar { #[inline] fn from_seed(seed: [u8; 32]) -> Xoshiro256StarStar { deal_with_zero_seed!(seed, Self); - let mut state = [0; 4]; - read_u64_into(&seed, &mut state); + let state: [u64; 4] = read_words(&seed); Xoshiro256StarStar { s: state } } @@ -109,7 +108,7 @@ impl RngCore for Xoshiro256StarStar { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } diff --git a/rand_xoshiro/src/xoshiro512plus.rs b/rand_xoshiro/src/xoshiro512plus.rs index 5bd276f7..f141bb3f 100644 --- a/rand_xoshiro/src/xoshiro512plus.rs +++ b/rand_xoshiro/src/xoshiro512plus.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -92,8 +92,7 @@ impl SeedableRng for Xoshiro512Plus { #[inline] fn from_seed(seed: Seed512) -> Xoshiro512Plus { deal_with_zero_seed!(seed, Self); - let mut state = [0; 8]; - read_u64_into(&seed.0, &mut state); + let state: [u64; 8] = read_words(&seed.0); Xoshiro512Plus { s: state } } @@ -120,7 +119,7 @@ impl RngCore for Xoshiro512Plus { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } diff --git a/rand_xoshiro/src/xoshiro512plusplus.rs b/rand_xoshiro/src/xoshiro512plusplus.rs index 82bcefc5..51e90337 100644 --- a/rand_xoshiro/src/xoshiro512plusplus.rs +++ b/rand_xoshiro/src/xoshiro512plusplus.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -91,8 +91,7 @@ impl SeedableRng for Xoshiro512PlusPlus { #[inline] fn from_seed(seed: Seed512) -> Xoshiro512PlusPlus { deal_with_zero_seed!(seed, Self); - let mut state = [0; 8]; - read_u64_into(&seed.0, &mut state); + let state: [u64; 8] = read_words(&seed.0); Xoshiro512PlusPlus { s: state } } @@ -119,7 +118,7 @@ impl RngCore for Xoshiro512PlusPlus { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } } diff --git a/rand_xoshiro/src/xoshiro512starstar.rs b/rand_xoshiro/src/xoshiro512starstar.rs index c4fbefad..6dc1a768 100644 --- a/rand_xoshiro/src/xoshiro512starstar.rs +++ b/rand_xoshiro/src/xoshiro512starstar.rs @@ -6,7 +6,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rand_core::le::{fill_bytes_via_next, read_u64_into}; +use rand_core::utils::{fill_bytes_via_next_word, read_words}; use rand_core::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -91,8 +91,7 @@ impl SeedableRng for Xoshiro512StarStar { #[inline] fn from_seed(seed: Seed512) -> Xoshiro512StarStar { deal_with_zero_seed!(seed, Self); - let mut state = [0; 8]; - read_u64_into(&seed.0, &mut state); + let state: [u64; 8] = read_words(&seed.0); Xoshiro512StarStar { s: state } } @@ -119,7 +118,7 @@ impl RngCore for Xoshiro512StarStar { #[inline] fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); + fill_bytes_via_next_word(dest, || self.next_u64()); } }