From ec59188025582fd91ab868206cfb3f3f05e27ade Mon Sep 17 00:00:00 2001 From: Nathan West Date: Tue, 2 Oct 2018 12:35:25 -0700 Subject: [PATCH] Make spec_extend use for_each() --- src/liballoc/vec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index e845438c0a836..2bc037e3fee12 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1822,12 +1822,12 @@ impl SpecExtend for Vec 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)