Create a new list with the contents initialized from a slice.
(slice: &[T], pool: &mut ListPool<T>)
| 275 | |
| 276 | /// Create a new list with the contents initialized from a slice. |
| 277 | pub fn from_slice(slice: &[T], pool: &mut ListPool<T>) -> Self { |
| 278 | let len = slice.len(); |
| 279 | if len == 0 { |
| 280 | return Self::new(); |
| 281 | } |
| 282 | |
| 283 | let block = pool.alloc(sclass_for_length(len)); |
| 284 | pool.data[block] = T::new(len); |
| 285 | pool.data[block + 1..=block + len].copy_from_slice(slice); |
| 286 | |
| 287 | Self { |
| 288 | index: (block + 1) as u32, |
| 289 | unused: PhantomData, |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | /// Returns `true` if the list has a length of 0. |
| 294 | pub fn is_empty(&self) -> bool { |
nothing calls this directly
no test coverage detected