Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Consoli <[email protected]>
  • Loading branch information
yoshuawuyts and matheus-consoli authored Nov 22, 2022
1 parent 932892c commit 654e993
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/utils/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ impl Indexer {
pub(crate) fn iter(&mut self) -> IndexIter {
// Increment the starting point for next time.
let offset = self.offset;
self.offset = self.offset.wrapping_rem(self.max);
self.offset = (self.offset + 1).wrapping_rem(self.max);

IndexIter {
iter: (0..self.max),
max: self.max,
offset,
}
}
Expand All @@ -30,7 +29,6 @@ impl Indexer {
pub(crate) struct IndexIter {
iter: ops::Range<usize>,
offset: usize,
max: usize,
}

impl Iterator for IndexIter {
Expand All @@ -39,6 +37,6 @@ impl Iterator for IndexIter {
fn next(&mut self) -> Option<Self::Item> {
self.iter
.next()
.map(|pos| (pos + self.offset).wrapping_rem(self.max))
.map(|pos| (pos + self.offset).wrapping_rem(self.iter.end))
}
}

0 comments on commit 654e993

Please sign in to comment.