boxing 0.1.2

Easy-to-use, cross-platform implementations for NaN and ptr boxes
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pub trait ArrayExt<const LEN: usize> {
    type Elem;

    fn truncate_to<const M: usize>(self) -> [Self::Elem; M];
}

impl<T: Default + Copy, const N: usize> ArrayExt<N> for [T; N] {
    type Elem = T;

    fn truncate_to<const M: usize>(self) -> [Self::Elem; M] {
        let copy_len = usize::min(N, M);
        let mut out = [T::default(); M];
        out[0..copy_len].copy_from_slice(&self[0..copy_len]);
        out
    }
}