Create a deep clone of the list, which does not alias the original list.
(&self, pool: &mut ListPool<T>)
| 348 | |
| 349 | /// Create a deep clone of the list, which does not alias the original list. |
| 350 | pub fn deep_clone(&self, pool: &mut ListPool<T>) -> Self { |
| 351 | match pool.len_of(self) { |
| 352 | None => return Self::new(), |
| 353 | Some(len) => { |
| 354 | let src = self.index as usize; |
| 355 | let block = pool.alloc(sclass_for_length(len)); |
| 356 | pool.data[block] = T::new(len); |
| 357 | pool.data.copy_within(src..src + len, block + 1); |
| 358 | |
| 359 | Self { |
| 360 | index: (block + 1) as u32, |
| 361 | unused: PhantomData, |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | /// Removes all elements from the list. |
| 368 | /// |