Skip to content

Commit e663b7a

Browse files
committed
fix clippy::if_not_else
1 parent bc7540f commit e663b7a

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/combinations_with_replacement.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ where
6565
fn next(&mut self) -> Option<Self::Item> {
6666
// If this is the first iteration, return early
6767
if self.first {
68-
// In empty edge cases, stop iterating immediately
69-
return if !(self.indices.is_empty() || self.pool.get_next()) {
70-
None
71-
// Otherwise, yield the initial state
72-
} else {
68+
return if self.indices.is_empty() || self.pool.get_next() {
69+
// yield the initial state
7370
self.first = false;
7471
Some(self.current())
72+
} else {
73+
// In empty edge cases, stop iterating immediately
74+
None
7575
};
7676
}
7777

src/minmax.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,7 @@ where
9191
};
9292
let first_key = key_for(&first);
9393
let second_key = key_for(&second);
94-
if !lt(&second, &first, &second_key, &first_key) {
95-
if lt(&first, &min, &first_key, &min_key) {
96-
min = first;
97-
min_key = first_key;
98-
}
99-
if !lt(&second, &max, &second_key, &max_key) {
100-
max = second;
101-
max_key = second_key;
102-
}
103-
} else {
94+
if lt(&second, &first, &second_key, &first_key) {
10495
if lt(&second, &min, &second_key, &min_key) {
10596
min = second;
10697
min_key = second_key;
@@ -109,6 +100,15 @@ where
109100
max = first;
110101
max_key = first_key;
111102
}
103+
} else {
104+
if lt(&first, &min, &first_key, &min_key) {
105+
min = first;
106+
min_key = first_key;
107+
}
108+
if !lt(&second, &max, &second_key, &max_key) {
109+
max = second;
110+
max_key = second_key;
111+
}
112112
}
113113
}
114114

src/with_position.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ impl<I: Iterator> Iterator for WithPosition<I> {
5555
fn next(&mut self) -> Option<Self::Item> {
5656
match self.peekable.next() {
5757
Some(item) => {
58-
if !self.handled_first {
58+
if self.handled_first {
59+
// Have seen the first item, and there's something left.
60+
// Peek to see if this is the last item.
61+
match self.peekable.peek() {
62+
Some(_) => Some((Position::Middle, item)),
63+
None => Some((Position::Last, item)),
64+
}
65+
} else {
5966
// Haven't seen the first item yet, and there is one to give.
6067
self.handled_first = true;
6168
// Peek to see if this is also the last item,
@@ -64,13 +71,6 @@ impl<I: Iterator> Iterator for WithPosition<I> {
6471
Some(_) => Some((Position::First, item)),
6572
None => Some((Position::Only, item)),
6673
}
67-
} else {
68-
// Have seen the first item, and there's something left.
69-
// Peek to see if this is the last item.
70-
match self.peekable.peek() {
71-
Some(_) => Some((Position::Middle, item)),
72-
None => Some((Position::Last, item)),
73-
}
7474
}
7575
}
7676
// Iterator is finished.

0 commit comments

Comments
 (0)