1
Fork 0

Use for_each in Iterator::partition

We already use this for `unzip`, but `partition` is not much different.
This commit is contained in:
Josh Stone 2019-06-10 14:06:56 -07:00
parent 02564de47b
commit c127f537e9

View file

@ -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)
}