generic_array/
impl_const_default.rs1use crate::{ArrayLength, GenericArray, GenericArrayImplEven, GenericArrayImplOdd};
4use const_default::ConstDefault;
5
6impl<T, U: ConstDefault> ConstDefault for GenericArrayImplEven<T, U> {
7 const DEFAULT: Self = Self {
8 parent1: U::DEFAULT,
9 parent2: U::DEFAULT,
10 _marker: core::marker::PhantomData,
11 };
12}
13
14impl<T: ConstDefault, U: ConstDefault> ConstDefault for GenericArrayImplOdd<T, U> {
15 const DEFAULT: Self = Self {
16 parent1: U::DEFAULT,
17 parent2: U::DEFAULT,
18 data: T::DEFAULT,
19 };
20}
21
22impl<T, U: ArrayLength> ConstDefault for GenericArray<T, U>
23where
24 U::ArrayType<T>: ConstDefault,
25{
26 const DEFAULT: Self = Self {
27 data: ConstDefault::DEFAULT,
28 };
29}
30
31impl<T: ConstDefault, U: ArrayLength> GenericArray<T, U>
33where
34 Self: ConstDefault,
35{
36 #[inline(always)]
38 pub const fn const_default() -> Self {
39 Self::DEFAULT
40 }
41}