Skip to content

Commit

Permalink
Powerset: use saturating add for position
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrozi committed Sep 13, 2020
1 parent b9edf18 commit 577ca75
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/powerset.rs
Expand Up @@ -51,15 +51,15 @@ impl<I> Iterator for Powerset<I>

fn next(&mut self) -> Option<Vec<I::Item>> {
if let Some(elt) = self.combs.next() {
self.pos += 1;
self.pos = self.pos.saturating_add(1);
Some(elt)
} else {
if self.done {
None
} else {
self.combs.init(self.combs.k() + 1);
if let Some(elt) = self.combs.next() {
self.pos += 1;
self.pos = self.pos.saturating_add(1);
Some(elt)
} else {
// None returned from a new Combinations indicates we're finished.
Expand Down

0 comments on commit 577ca75

Please sign in to comment.