From c127f537e9bfbe844a78ba542d41bea8aa26aa89 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 10 Jun 2019 14:06:56 -0700 Subject: [PATCH] Use `for_each` in `Iterator::partition` We already use this for `unzip`, but `partition` is not much different. --- src/libcore/iter/traits/iterator.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index d0fdd79473e67..30923c7414504 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -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) }