concision_params/traits/
iterators.rs1use ndarray::iter as nditer;
7use ndarray::{ArrayBase, Data, DataMut, Dimension};
8
9pub trait NdIter<A, D>
10where
11 D: Dimension,
12{
13 type Iter<'b, T>
14 where
15 T: 'b,
16 Self: 'b;
17 fn nditer(&self) -> Self::Iter<'_, A>;
19}
20
21pub trait NdIterMut<A, D>
22where
23 D: Dimension,
24{
25 type IterMut<'b, T>
26 where
27 T: 'b,
28 Self: 'b;
29 fn nditer_mut(&mut self) -> Self::IterMut<'_, A>;
31}
32
33impl<A, S, D> NdIter<A, D> for ArrayBase<S, D, A>
38where
39 S: Data<Elem = A>,
40 D: Dimension,
41{
42 type Iter<'b, T>
43 = nditer::Iter<'b, T, D>
44 where
45 T: 'b,
46 Self: 'b;
47
48 fn nditer(&self) -> Self::Iter<'_, A> {
49 self.iter()
50 }
51}
52
53impl<A, S, D> NdIterMut<A, D> for ArrayBase<S, D, A>
54where
55 S: DataMut<Elem = A>,
56 D: Dimension,
57{
58 type IterMut<'b, T>
59 = nditer::IterMut<'b, T, D>
60 where
61 T: 'b,
62 Self: 'b;
63
64 fn nditer_mut(&mut self) -> Self::IterMut<'_, A> {
65 self.iter_mut()
66 }
67}