Appends multiple elements to the back of the list.
(&mut self, elements: I, pool: &mut ListPool<T>)
| 464 | |
| 465 | /// Appends multiple elements to the back of the list. |
| 466 | pub fn extend<I>(&mut self, elements: I, pool: &mut ListPool<T>) |
| 467 | where |
| 468 | I: IntoIterator<Item = T>, |
| 469 | { |
| 470 | let iterator = elements.into_iter(); |
| 471 | let (len, upper) = iterator.size_hint(); |
| 472 | // On most iterators this check is optimized down to `true`. |
| 473 | if upper == Some(len) { |
| 474 | let data = self.grow(len, pool); |
| 475 | let offset = data.len() - len; |
| 476 | for (src, dst) in iterator.zip(data[offset..].iter_mut()) { |
| 477 | *dst = src; |
| 478 | } |
| 479 | } else { |
| 480 | for x in iterator { |
| 481 | self.push(x, pool); |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | /// Copies a slice from an entity list in the same pool to a position in this one. |
| 487 | /// |