1
Fork 0

Make spec_extend use for_each()

This commit is contained in:
Nathan West 2018-10-02 12:35:25 -07:00 committed by GitHub
parent 1c5e9c68ea
commit ec59188025
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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