Skip to content

Commit

Permalink
Rollup merge of rust-lang#61726 - cuviper:partition-for_each, r=scottmcm
Browse files Browse the repository at this point in the history
Use `for_each` in `Iterator::partition`

We already use this for `unzip`, but `partition` is not much different.
  • Loading branch information
Centril authored Jun 11, 2019
2 parents 2f1d360 + c127f53 commit 681712b
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 681712b

Please sign in to comment.