Skip to content

Commit

Permalink
Make spec_extend use for_each()
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucretiel committed Oct 2, 2018
1 parent 1c5e9c6 commit ec59188
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ec59188

Please sign in to comment.