Removes the element at `index` in constant time by switching it with the last element of the list.
(&mut self, index: usize, pool: &mut ListPool<T>)
| 584 | /// Removes the element at `index` in constant time by switching it with the last element of |
| 585 | /// the list. |
| 586 | pub fn swap_remove(&mut self, index: usize, pool: &mut ListPool<T>) { |
| 587 | let seq = self.as_mut_slice(pool); |
| 588 | let len = seq.len(); |
| 589 | debug_assert!(index < len); |
| 590 | if index != len - 1 { |
| 591 | seq.swap(index, len - 1); |
| 592 | } |
| 593 | |
| 594 | self.remove_last(len, pool); |
| 595 | } |
| 596 | |
| 597 | /// Shortens the list down to `len` elements. |
| 598 | /// |