]> git.lizzy.rs Git - rust.git/blobdiff - library/alloc/src/collections/btree/mod.rs
Rollup merge of #75485 - RalfJung:pin, r=nagisa
[rust.git] / library / alloc / src / collections / btree / mod.rs
index 543ff41a4d48d55fc2b4616f39a8a17cc69c2a87..6c8a588eb58f33db5d98c32d2f53f2cb7695d80a 100644 (file)
@@ -25,3 +25,30 @@ pub unsafe fn unwrap_unchecked<T>(val: Option<T>) -> T {
         }
     })
 }
+
+#[cfg(test)]
+/// XorShiftRng
+struct DeterministicRng {
+    x: u32,
+    y: u32,
+    z: u32,
+    w: u32,
+}
+
+#[cfg(test)]
+impl DeterministicRng {
+    fn new() -> Self {
+        DeterministicRng { x: 0x193a6754, y: 0xa8a7d469, z: 0x97830e05, w: 0x113ba7bb }
+    }
+
+    fn next(&mut self) -> u32 {
+        let x = self.x;
+        let t = x ^ (x << 11);
+        self.x = self.y;
+        self.y = self.z;
+        self.z = self.w;
+        let w_ = self.w;
+        self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8));
+        self.w
+    }
+}