linearize/impls/
phantom_pinned.rs

1use {crate::Linearize, core::marker::PhantomPinned};
2
3unsafe impl Linearize for PhantomPinned {
4    type Storage<T> = [T; 1];
5    type CopyStorage<T>
6        = [T; 1]
7    where
8        T: Copy;
9    const LENGTH: usize = 1;
10
11    #[inline]
12    fn linearize(&self) -> usize {
13        0
14    }
15
16    #[inline]
17    unsafe fn from_linear_unchecked(_linear: usize) -> Self
18    where
19        Self: Sized,
20    {
21        PhantomPinned
22    }
23}
24
25impl_assert!(PhantomPinned, 1);
26
27#[test]
28fn test() {
29    assert_roundtrip!(PhantomPinned, 0);
30}