Make spec_extend use for_each()
This commit is contained in:
parent
1c5e9c68ea
commit
ec59188025
1 changed files with 2 additions and 2 deletions
|
@ -1822,12 +1822,12 @@ impl<T, I> SpecExtend<T, I> for Vec<T>
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut ptr = self.as_mut_ptr().add(self.len());
|
let mut ptr = self.as_mut_ptr().add(self.len());
|
||||||
let mut local_len = SetLenOnDrop::new(&mut 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::write(ptr, element);
|
||||||
ptr = ptr.offset(1);
|
ptr = ptr.offset(1);
|
||||||
// NB can't overflow since we would have had to alloc the address space
|
// NB can't overflow since we would have had to alloc the address space
|
||||||
local_len.increment_len(1);
|
local_len.increment_len(1);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.extend_desugared(iterator)
|
self.extend_desugared(iterator)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue