Skip to content

Commit

Permalink
Use for_each in Iterator::partition
Browse files Browse the repository at this point in the history
We already use this for `unzip`, but `partition` is not much different.
  • Loading branch information
cuviper committed Jun 10, 2019
1 parent 02564de commit c127f53
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libcore/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1495,13 +1495,13 @@ pub trait Iterator {
let mut left: B = Default::default();
let mut right: B = Default::default();

for x in self {
self.for_each(|x| {
if f(&x) {
left.extend(Some(x))
} else {
right.extend(Some(x))
}
}
});

(left, right)
}
Expand Down

0 comments on commit c127f53

Please sign in to comment.