]> git.proxmox.com Git - cargo.git/blobdiff - vendor/rand_xoshiro/src/xoshiro256starstar.rs
New upstream version 0.63.1
[cargo.git] / vendor / rand_xoshiro / src / xoshiro256starstar.rs
index 2cc2029141f956c07e48f090d80b19473b20eb24..3ee41ae45c76ee76765669a8a22e98b989e14ef8 100644 (file)
@@ -19,7 +19,7 @@ use rand_core::{SeedableRng, RngCore, Error};
 /// The algorithm used here is translated from [the `xoshiro256starstar.c`
 /// reference source code](http://xoshiro.di.unimi.it/xoshiro256starstar.c) by
 /// David Blackman and Sebastiano Vigna.
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Eq)]
 #[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
 pub struct Xoshiro256StarStar {
     s: [u64; 4],
@@ -83,7 +83,9 @@ impl SeedableRng for Xoshiro256StarStar {
 impl RngCore for Xoshiro256StarStar {
     #[inline]
     fn next_u32(&mut self) -> u32 {
-        self.next_u64() as u32
+        // The lowest bits have some linear dependencies, so we use the
+        // upper bits instead.
+        (self.next_u64() >> 32) as u32
     }
 
     #[inline]