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
use crate::{funvec_ref::FunVecRef, funvec_val::FunVec, index::IntoIndex};

const DIM: usize = 1;

// val
impl<T: Clone + Copy> FunVec<DIM, T> for Vec<T> {
    #[inline(always)]
    fn at<Idx: IntoIndex<DIM>>(&self, index: Idx) -> Option<T> {
        self.get(index.into_index()[0]).copied()
    }
}
impl<const N: usize, T: Clone + Copy> FunVec<DIM, T> for [T; N] {
    #[inline(always)]
    fn at<Idx: IntoIndex<DIM>>(&self, index: Idx) -> Option<T> {
        self.get(index.into_index()[0]).copied()
    }
}

// ref
impl<T> FunVecRef<DIM, T> for Vec<T> {
    #[inline(always)]
    fn ref_at<Idx: IntoIndex<DIM>>(&self, index: Idx) -> Option<&T> {
        self.get(index.into_index()[0])
    }
}
impl<const N: usize, T> FunVecRef<DIM, T> for [T; N] {
    #[inline(always)]
    fn ref_at<Idx: IntoIndex<DIM>>(&self, index: Idx) -> Option<&T> {
        self.get(index.into_index()[0])
    }
}