(slice: SlimSliceBox<T>)
| 369 | impl<T> From<SlimSliceBox<T>> for Box<[T]> { |
| 370 | #[inline] |
| 371 | fn from(slice: SlimSliceBox<T>) -> Self { |
| 372 | let slice = ManuallyDrop::new(slice); |
| 373 | let (ptr, len) = slice.raw.split(); |
| 374 | // SAFETY: All paths to creating a `SlimSliceBox` |
| 375 | // go through `SlimSliceBox::from_boxed_unchecked` |
| 376 | // which requires a valid `Box<[T]>`. |
| 377 | // The function also uses `Box::into_raw` |
| 378 | // and the original length is kept. |
| 379 | // |
| 380 | // It therefore follows that if we reuse the same |
| 381 | // pointer and length as given to us by a valid `Box<[T]>`, |
| 382 | // we can use `Box::from_raw` to reconstruct the `Box<[T]>`. |
| 383 | // |
| 384 | // We also no longer claim ownership of the data pointed to by `ptr` |
| 385 | // by virtue of `ManuallyDrop` preventing `Drop for SlimSliceBox<T>`. |
| 386 | unsafe { Box::from_raw(slice_from_raw_parts_mut(ptr, len)) } |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 |
nothing calls this directly
no test coverage detected