use the module operator to calculate next index

pull/388/head
Felipe Sere 5 years ago
parent 486f9a964c
commit 8126bb1882

@ -22,11 +22,7 @@ impl<T: Copy> Stream for Cycle<T> {
let next = self.index + 1;
if next >= self.len {
self.as_mut().index = 0;
} else {
self.as_mut().index = next;
}
self.as_mut().index = next % self.len;
Poll::Ready(Some(value))
}

Loading…
Cancel
Save