|
101 | 101 | /// ``` |
102 | 102 | #[macro_export] |
103 | 103 | macro_rules! azip { |
104 | | - // Indexed with a single producer and no trailing comma. |
105 | | - ((index $index:pat, $first_pat:pat in $first_prod:expr) $body:expr) => { |
| 104 | + // Indexed with a single producer |
| 105 | + // we allow an optional trailing comma after the producers in each rule. |
| 106 | + ((index $index:pat, $first_pat:pat in $first_prod:expr $(,)?) $body:expr) => { |
106 | 107 | $crate::Zip::indexed($first_prod).apply(|$index, $first_pat| $body) |
107 | 108 | }; |
108 | | - // Indexed with more than one producer and no trailing comma. |
109 | | - ((index $index:pat, $first_pat:pat in $first_prod:expr, $($pat:pat in $prod:expr),*) $body:expr) => { |
| 109 | + // Indexed with more than one producer |
| 110 | + ((index $index:pat, $first_pat:pat in $first_prod:expr, $($pat:pat in $prod:expr),* $(,)?) $body:expr) => { |
110 | 111 | $crate::Zip::indexed($first_prod) |
111 | 112 | $(.and($prod))* |
112 | 113 | .apply(|$index, $first_pat, $($pat),*| $body) |
113 | 114 | }; |
114 | | - // Indexed with trailing comma. |
115 | | - ((index $index:pat, $($pat:pat in $prod:expr),+,) $body:expr) => { |
116 | | - azip!((index $index, $($pat in $prod),+) $body) |
117 | | - }; |
118 | | - // Unindexed with a single producer and no trailing comma. |
119 | | - (($first_pat:pat in $first_prod:expr) $body:expr) => { |
| 115 | + // Unindexed with a single producer |
| 116 | + (($first_pat:pat in $first_prod:expr $(,)?) $body:expr) => { |
120 | 117 | $crate::Zip::from($first_prod).apply(|$first_pat| $body) |
121 | 118 | }; |
122 | | - // Unindexed with more than one producer and no trailing comma. |
123 | | - (($first_pat:pat in $first_prod:expr, $($pat:pat in $prod:expr),*) $body:expr) => { |
| 119 | + // Unindexed with more than one producer |
| 120 | + (($first_pat:pat in $first_prod:expr, $($pat:pat in $prod:expr),* $(,)?) $body:expr) => { |
124 | 121 | $crate::Zip::from($first_prod) |
125 | 122 | $(.and($prod))* |
126 | 123 | .apply(|$first_pat, $($pat),*| $body) |
127 | 124 | }; |
128 | | - // Unindexed with trailing comma. |
129 | | - (($($pat:pat in $prod:expr),+,) $body:expr) => { |
130 | | - azip!(($($pat in $prod),+) $body) |
131 | | - }; |
132 | 125 | } |
0 commit comments