linearize/impls/
unit.rs

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