rust/lfprng/src/lib.rs
changeset 15115 de32299de704
parent 14152 5acfdf49742d
child 15902 9b73594ac986
--- a/rust/lfprng/src/lib.rs	Tue Jun 04 20:01:37 2019 +0300
+++ b/rust/lfprng/src/lib.rs	Tue Jun 04 21:24:07 2019 +0200
@@ -16,14 +16,19 @@
             index: 54,
         };
 
-        for _i in 0..2048 {
-            prng.get_next();
-        }
+        prng.discard(2048);
 
         prng
     }
 
     #[inline]
+    pub fn discard(&mut self, count: usize) {
+        for _i in 0..count {
+            self.get_next();
+        }
+    }
+
+    #[inline]
     fn get_next(&mut self) -> u32 {
         self.index = (self.index + 1) & 0x3f;
         self.circular_buffer[self.index] = (self.circular_buffer[(self.index + 40) & 0x3f]