about summary refs log tree commit diff
path: root/src/liballoc/vec.rs
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-10-04 12:20:08 +0200
committerGitHub <noreply@github.com>2018-10-04 12:20:08 +0200
commitc215c1927af2eee46e7c36a4fdd7e2871a3f18e2 (patch)
tree86cd6718d714a0f5788254d355a55f9e044c5eca /src/liballoc/vec.rs
parentbc4f86909ea5e08a9114c70eef29942a4ea2c459 (diff)
parentec59188025582fd91ab868206cfb3f3f05e27ade (diff)
downloadrust-c215c1927af2eee46e7c36a4fdd7e2871a3f18e2.tar.gz
rust-c215c1927af2eee46e7c36a4fdd7e2871a3f18e2.zip
Rollup merge of #54761 - Lucretiel:patch-1, r=cramertj
Make spec_extend use for_each()

`for_each` will use an iterator's own implementation of `try_fold`, which I understand to be generally preferable (because nested iterator adapter's will use each other's `try_fold` and be designed for the specific adaptation in a way that promotes performance and inlining.
Diffstat (limited to 'src/liballoc/vec.rs')
-rw-r--r--src/liballoc/vec.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index e845438c0a8..2bc037e3fee 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -1822,12 +1822,12 @@ impl<T, I> SpecExtend<T, I> for Vec<T>
             unsafe {
                 let mut ptr = self.as_mut_ptr().add(self.len());
                 let mut local_len = SetLenOnDrop::new(&mut self.len);
-                for element in iterator {
+                iterator.for_each(move |element| {
                     ptr::write(ptr, element);
                     ptr = ptr.offset(1);
                     // NB can't overflow since we would have had to alloc the address space
                     local_len.increment_len(1);
-                }
+                });
             }
         } else {
             self.extend_desugared(iterator)