1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use ::core::{
marker::{PhantomData, PhantomPinned},
mem::MaybeUninit,
};
use crate::{ops::IndexMutRaw, DropRaw, Mut};
macro_rules! impl_builtin {
($($ty:ty),*) => {
$(
impl DropRaw for $ty {
#[inline]
unsafe fn drop_raw(_: Mut<'_, Self>) {}
}
)*
};
}
impl_builtin!(i8, u8, bool, (), PhantomPinned);
impl<T: DropRaw, const N: usize> DropRaw for [T; N] {
#[inline]
unsafe fn drop_raw(mut this: Mut<'_, Self>) {
for i in 0..N {
unsafe {
DropRaw::drop_raw(IndexMutRaw::index_mut_raw(this.as_mut(), i));
}
}
}
}
impl<T: DropRaw> DropRaw for [T] {
#[inline]
unsafe fn drop_raw(mut this: Mut<'_, Self>) {
for i in 0..this.len() {
unsafe {
DropRaw::drop_raw(IndexMutRaw::index_mut_raw(this.as_mut(), i));
}
}
}
}
impl<T: ?Sized> DropRaw for PhantomData<T> {
#[inline]
unsafe fn drop_raw(_: Mut<'_, Self>) {}
}
impl<T> DropRaw for MaybeUninit<T> {
#[inline]
unsafe fn drop_raw(_: Mut<'_, Self>) {}
}