Skip to content

Commit

Permalink
Update rand_xoshiro to rand master
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed May 25, 2024
1 parent 588d12a commit 002b315
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 103 deletions.
2 changes: 1 addition & 1 deletion rand_xoshiro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rust-version = "1.61"
serde1 = ["serde"]

[dependencies]
rand_core = { version = "0.6" }
rand_core = { version = "=0.9.0-alpha.1" }
serde = { version = "1", features = ["derive"], optional=true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rand_xoshiro/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
macro_rules! from_splitmix {
($seed:expr) => {{
let mut rng = crate::SplitMix64::seed_from_u64($seed);
Self::from_rng(&mut rng).unwrap()
Self::from_rng(&mut rng)
}};
}

Expand Down
10 changes: 3 additions & 7 deletions rand_xoshiro/src/splitmix64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rand_core::impls::fill_bytes_via_next;
use rand_core::le::read_u64_into;
use rand_core::{Error, RngCore, SeedableRng};
use rand_core::{RngCore, SeedableRng};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -57,14 +57,10 @@ impl RngCore for SplitMix64 {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(SplitMix64);

impl SeedableRng for SplitMix64 {
type Seed = [u8; 8];

Expand Down
8 changes: 2 additions & 6 deletions rand_xoshiro/src/xoroshiro128plus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,10 @@ impl RngCore for Xoroshiro128Plus {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoroshiro128Plus);

impl SeedableRng for Xoroshiro128Plus {
type Seed = [u8; 16];

Expand Down
8 changes: 2 additions & 6 deletions rand_xoshiro/src/xoroshiro128plusplus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,10 @@ impl RngCore for Xoroshiro128PlusPlus {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoroshiro128PlusPlus);

impl SeedableRng for Xoroshiro128PlusPlus {
type Seed = [u8; 16];

Expand Down
8 changes: 2 additions & 6 deletions rand_xoshiro/src/xoroshiro128starstar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,10 @@ impl RngCore for Xoroshiro128StarStar {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoroshiro128StarStar);

impl SeedableRng for Xoroshiro128StarStar {
type Seed = [u8; 16];

Expand Down
8 changes: 2 additions & 6 deletions rand_xoshiro/src/xoroshiro64star.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,10 @@ impl RngCore for Xoroshiro64Star {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoroshiro64Star);

impl SeedableRng for Xoroshiro64Star {
type Seed = [u8; 8];

Expand Down
8 changes: 2 additions & 6 deletions rand_xoshiro/src/xoroshiro64starstar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,10 @@ impl RngCore for Xoroshiro64StarStar {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoroshiro64StarStar);

impl SeedableRng for Xoroshiro64StarStar {
type Seed = [u8; 8];

Expand Down
10 changes: 2 additions & 8 deletions rand_xoshiro/src/xoshiro128plus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32};
use rand_core::le::read_u32_into;
use rand_core::{Error, RngCore, SeedableRng};
use rand_core::{RngCore, SeedableRng};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -93,14 +93,8 @@ impl RngCore for Xoshiro128Plus {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoshiro128Plus);
#[cfg(test)]
mod tests {
use super::*;
Expand Down
10 changes: 3 additions & 7 deletions rand_xoshiro/src/xoshiro128plusplus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32};
use rand_core::le::read_u32_into;
use rand_core::{Error, RngCore, SeedableRng};
use rand_core::{RngCore, SeedableRng};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -92,14 +92,10 @@ impl RngCore for Xoshiro128PlusPlus {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoshiro128PlusPlus);

#[cfg(test)]
mod tests {
use super::*;
Expand Down
10 changes: 3 additions & 7 deletions rand_xoshiro/src/xoshiro128starstar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32};
use rand_core::le::read_u32_into;
use rand_core::{Error, RngCore, SeedableRng};
use rand_core::{RngCore, SeedableRng};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -92,14 +92,10 @@ impl RngCore for Xoshiro128StarStar {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoshiro128StarStar);

#[cfg(test)]
mod tests {
use super::*;
Expand Down
10 changes: 3 additions & 7 deletions rand_xoshiro/src/xoshiro256plus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rand_core::impls::fill_bytes_via_next;
use rand_core::le::read_u64_into;
use rand_core::{Error, RngCore, SeedableRng};
use rand_core::{RngCore, SeedableRng};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -113,14 +113,10 @@ impl RngCore for Xoshiro256Plus {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoshiro256Plus);

#[cfg(test)]
mod tests {
use super::*;
Expand Down
10 changes: 3 additions & 7 deletions rand_xoshiro/src/xoshiro256plusplus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rand_core::impls::fill_bytes_via_next;
use rand_core::le::read_u64_into;
use rand_core::{Error, RngCore, SeedableRng};
use rand_core::{RngCore, SeedableRng};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -112,14 +112,10 @@ impl RngCore for Xoshiro256PlusPlus {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoshiro256PlusPlus);

#[cfg(test)]
mod tests {
use super::*;
Expand Down
10 changes: 3 additions & 7 deletions rand_xoshiro/src/xoshiro256starstar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rand_core::impls::fill_bytes_via_next;
use rand_core::le::read_u64_into;
use rand_core::{Error, RngCore, SeedableRng};
use rand_core::{RngCore, SeedableRng};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -112,14 +112,10 @@ impl RngCore for Xoshiro256StarStar {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoshiro256StarStar);

#[cfg(test)]
mod tests {
use super::*;
Expand Down
10 changes: 3 additions & 7 deletions rand_xoshiro/src/xoshiro512plus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rand_core::impls::fill_bytes_via_next;
use rand_core::le::read_u64_into;
use rand_core::{Error, RngCore, SeedableRng};
use rand_core::{RngCore, SeedableRng};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -123,14 +123,10 @@ impl RngCore for Xoshiro512Plus {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoshiro512Plus);

#[cfg(test)]
mod tests {
use super::*;
Expand Down
10 changes: 3 additions & 7 deletions rand_xoshiro/src/xoshiro512plusplus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rand_core::impls::fill_bytes_via_next;
use rand_core::le::read_u64_into;
use rand_core::{Error, RngCore, SeedableRng};
use rand_core::{RngCore, SeedableRng};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -122,14 +122,10 @@ impl RngCore for Xoshiro512PlusPlus {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoshiro512PlusPlus);

#[cfg(test)]
mod tests {
use super::*;
Expand Down
10 changes: 3 additions & 7 deletions rand_xoshiro/src/xoshiro512starstar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use rand_core::impls::fill_bytes_via_next;
use rand_core::le::read_u64_into;
use rand_core::{Error, RngCore, SeedableRng};
use rand_core::{RngCore, SeedableRng};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -122,14 +122,10 @@ impl RngCore for Xoshiro512StarStar {
fn fill_bytes(&mut self, dest: &mut [u8]) {
fill_bytes_via_next(self, dest);
}

#[inline]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
self.fill_bytes(dest);
Ok(())
}
}

rand_core::impl_try_rng_from_rng_core!(Xoshiro512StarStar);

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 002b315

Please sign in to comment.