2 use core::slice::{self};
4 // A helper struct for in-place iteration that drops the destination slice of iteration,
5 // i.e. the head. The source slice (the tail) is dropped by IntoIter.
6 pub(super) struct InPlaceDrop<T> {
7 pub(super) inner: *mut T,
8 pub(super) dst: *mut T,
11 impl<T> InPlaceDrop<T> {
12 fn len(&self) -> usize {
13 unsafe { self.dst.sub_ptr(self.inner) }
17 impl<T> Drop for InPlaceDrop<T> {
21 ptr::drop_in_place(slice::from_raw_parts_mut(self.inner, self.len()));