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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#[macro_export]
macro_rules! par_azip {
(@parse [index => $a:expr, $($aa:expr,)*] $t1:tt in $t2:tt) => {
par_azip!(@finish ($crate::ndarray::Zip::indexed($a)) [$($aa,)*] $t1 in $t2)
};
(@parse [$a:expr, $($aa:expr,)*] $t1:tt in $t2:tt) => {
par_azip!(@finish ($crate::ndarray::Zip::from($a)) [$($aa,)*] $t1 in $t2)
};
(@finish ($z:expr) [$($aa:expr,)*] [$($p:pat,)+] in { $($t:tt)*}) => {
use $crate::prelude::*;
#[allow(unused_mut)]
($z)
$(
.and($aa)
)*
.par_apply(|$($p),+| {
$($t)*
})
};
(@parse [] [] index $i:pat, $($t:tt)*) => {
par_azip!(@parse [index =>] [$i,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] mut $x:ident ($e:expr) $($t:tt)*) => {
par_azip!(@parse [$($exprs)* $e,] [$($pats)* mut $x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] mut $x:ident $($t:tt)*) => {
par_azip!(@parse [$($exprs)* &mut $x,] [$($pats)* mut $x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] , $($t:tt)*) => {
par_azip!(@parse [$($exprs)*] [$($pats)*] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] ref $x:ident ($e:expr) $($t:tt)*) => {
par_azip!(@parse [$($exprs)* $e,] [$($pats)* $x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] ref $x:ident $($t:tt)*) => {
par_azip!(@parse [$($exprs)* &$x,] [$($pats)* $x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] $x:ident ($e:expr) $($t:tt)*) => {
par_azip!(@parse [$($exprs)* $e,] [$($pats)* &$x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] $x:ident $($t:tt)*) => {
par_azip!(@parse [$($exprs)* &$x,] [$($pats)* &$x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] $($t:tt)*) => { };
($($t:tt)*) => {
par_azip!(@parse [] [] $($t)*);
}
}