Implement Iterator trait for LaggedFibonacciPRNG
authorunc0rr
Sun, 14 Oct 2018 18:23:19 +0200
changeset 13904 3f0576157749
parent 13903 e26573441808
child 13905 fed924791e06
Implement Iterator trait for LaggedFibonacciPRNG
rust/lfprng/src/lib.rs
--- a/rust/lfprng/src/lib.rs	Sun Oct 14 18:01:58 2018 +0200
+++ b/rust/lfprng/src/lib.rs	Sun Oct 14 18:23:19 2018 +0200
@@ -46,6 +46,15 @@
     }
 }
 
+impl Iterator for LaggedFibonacciPRNG {
+    type Item = u32;
+
+    fn next(&mut self) -> Option<u32> {
+        self.get_next();
+        Some(self.get_next())
+    }
+}
+
 #[cfg(test)]
 #[test]
 fn compatibility() {