Thanks to visit codestin.com
Credit goes to docs.rs

ndarray/parallel/
into_impls.rs

1use crate::{ArcArray, Array, ArrayView, ArrayViewMut, Dimension};
2
3use super::prelude::IntoParallelIterator;
4use super::Parallel;
5
6/// Requires crate feature `rayon`.
7impl<'a, A, D> IntoParallelIterator for &'a Array<A, D>
8where
9    D: Dimension,
10    A: Sync,
11{
12    type Item = &'a A;
13    type Iter = Parallel<ArrayView<'a, A, D>>;
14    fn into_par_iter(self) -> Self::Iter
15    {
16        self.view().into_par_iter()
17    }
18}
19
20// This is allowed: goes through `.view()`
21/// Requires crate feature `rayon`.
22impl<'a, A, D> IntoParallelIterator for &'a ArcArray<A, D>
23where
24    D: Dimension,
25    A: Sync,
26{
27    type Item = &'a A;
28    type Iter = Parallel<ArrayView<'a, A, D>>;
29    fn into_par_iter(self) -> Self::Iter
30    {
31        self.view().into_par_iter()
32    }
33}
34
35/// Requires crate feature `rayon`.
36impl<'a, A, D> IntoParallelIterator for &'a mut Array<A, D>
37where
38    D: Dimension,
39    A: Sync + Send,
40{
41    type Item = &'a mut A;
42    type Iter = Parallel<ArrayViewMut<'a, A, D>>;
43    fn into_par_iter(self) -> Self::Iter
44    {
45        self.view_mut().into_par_iter()
46    }
47}
48
49// This is allowed: goes through `.view_mut()`, which is unique access
50/// Requires crate feature `rayon`.
51impl<'a, A, D> IntoParallelIterator for &'a mut ArcArray<A, D>
52where
53    D: Dimension,
54    A: Sync + Send + Clone,
55{
56    type Item = &'a mut A;
57    type Iter = Parallel<ArrayViewMut<'a, A, D>>;
58    fn into_par_iter(self) -> Self::Iter
59    {
60        self.view_mut().into_par_iter()
61    }
62}