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
use crate::arrays::Array;
use crate::traits::{
    create::ArrayCreate,
    types::numeric::Numeric,
};

impl <N: Numeric> IntoIterator for Array<N> {
    type Item = N;
    type IntoIter = std::vec::IntoIter<N>;

    fn into_iter(self) -> Self::IntoIter {
        self.elements.into_iter()
    }
}

impl<'a, N: Numeric> IntoIterator for &'a Array<N> {
    type Item = &'a N;
    type IntoIter = std::slice::Iter<'a, N>;

    fn into_iter(self) -> Self::IntoIter {
        self.elements.iter()
    }
}

impl <N: Numeric> FromIterator<N> for Array<N> {

    fn from_iter<T: IntoIterator<Item=N>>(iter: T) -> Self {
        Self::flat(iter.into_iter().collect()).unwrap()
    }
}