From 8126bb18821dd9be167ee892b9db8afa1e2d19b9 Mon Sep 17 00:00:00 2001 From: Felipe Sere Date: Thu, 24 Oct 2019 16:40:27 -0500 Subject: [PATCH] use the module operator to calculate next index --- src/stream/cycle.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/stream/cycle.rs b/src/stream/cycle.rs index 9438469..135a430 100644 --- a/src/stream/cycle.rs +++ b/src/stream/cycle.rs @@ -22,11 +22,7 @@ impl Stream for Cycle { 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)) }