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
use crate::{ArrayLength, GenericArray, GenericArrayImplEven, GenericArrayImplOdd};
use const_default::ConstDefault;
impl<T, U: ConstDefault> ConstDefault for GenericArrayImplEven<T, U> {
const DEFAULT: Self = Self {
parent1: U::DEFAULT,
parent2: U::DEFAULT,
_marker: core::marker::PhantomData,
};
}
impl<T: ConstDefault, U: ConstDefault> ConstDefault for GenericArrayImplOdd<T, U> {
const DEFAULT: Self = Self {
parent1: U::DEFAULT,
parent2: U::DEFAULT,
data: T::DEFAULT,
};
}
impl<T, U: ArrayLength> ConstDefault for GenericArray<T, U>
where
U::ArrayType<T>: ConstDefault,
{
const DEFAULT: Self = Self {
data: ConstDefault::DEFAULT,
};
}
impl<T: ConstDefault, U: ArrayLength> GenericArray<T, U>
where
Self: ConstDefault,
{
#[inline(always)]
pub const fn const_default() -> Self {
Self::DEFAULT
}
}