use the module operator to calculate next index

poc-serde-support
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; let next = self.index + 1;
if next >= self.len { self.as_mut().index = next % self.len;
self.as_mut().index = 0;
} else {
self.as_mut().index = next;
}
Poll::Ready(Some(value)) Poll::Ready(Some(value))
} }

Loading…
Cancel
Save