Skip to content

Commit

Permalink
partition: use rfind
Browse files Browse the repository at this point in the history
And then no need for a named loop anymore.
  • Loading branch information
Philippe-Cholet committed Dec 10, 2023
1 parent 2c5a8a8 commit e286c1b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4054,18 +4054,11 @@ where
{
let mut split_index = 0;
let mut iter = iter.into_iter();
'main: while let Some(front) = iter.next() {
while let Some(front) = iter.next() {
if !pred(front) {
loop {
match iter.next_back() {
Some(back) => {
if pred(back) {
std::mem::swap(front, back);
break;
}
}
None => break 'main,
}
match iter.rfind(|back| pred(back)) {
Some(back) => std::mem::swap(front, back),
None => break,
}
}
split_index += 1;
Expand Down

0 comments on commit e286c1b

Please sign in to comment.