33#![ feature( macro_metavar_expr) ]
44
55fn main ( ) {
6- macro_rules! one_nested_count_and_length {
6+ macro_rules! one_nested_count_and_len {
77 ( $( [ $( $l: literal ) ,* ] ) ,* ) => {
88 [
99 // outer-most repetition
1010 $(
1111 // inner-most repetition
1212 $(
13- ${ ignore( $l) } ${ index( ) } , ${ length ( ) } ,
13+ ${ ignore( $l) } ${ index( ) } , ${ len ( ) } ,
1414 ) *
15- ${ count( $l) } , ${ index( ) } , ${ length ( ) } ,
15+ ${ count( $l) } , ${ index( ) } , ${ len ( ) } ,
1616 ) *
1717 ${ count( $l) } ,
1818 ]
1919 } ;
2020 }
2121 assert_eq ! (
22- one_nested_count_and_length !( [ "foo" ] , [ "bar" , "baz" ] ) ,
22+ one_nested_count_and_len !( [ "foo" ] , [ "bar" , "baz" ] ) ,
2323 [
2424 // # ["foo"]
2525
2626 // ## inner-most repetition (first iteration)
2727 //
2828 // `index` is 0 because this is the first inner-most iteration.
29- // `length ` is 1 because there is only one inner-most repetition, "foo".
29+ // `len ` is 1 because there is only one inner-most repetition, "foo".
3030 0 , 1 ,
31-
3231 // ## outer-most repetition (first iteration)
3332 //
3433 // `count` is 1 because of "foo", i,e, `$l` has only one repetition,
3534 // `index` is 0 because this is the first outer-most iteration.
36- // `length ` is 2 because there are 2 outer-most repetitions, ["foo"] and ["bar", "baz"]
35+ // `len ` is 2 because there are 2 outer-most repetitions, ["foo"] and ["bar", "baz"]
3736 1 , 0 , 2 ,
38-
3937 // # ["bar", "baz"]
4038
4139 // ## inner-most repetition (first iteration)
4240 //
4341 // `index` is 0 because this is the first inner-most iteration
44- // `length ` is 2 because there are repetitions, "bar" and "baz"
42+ // `len ` is 2 because there are repetitions, "bar" and "baz"
4543 0 , 2 ,
46-
4744 // ## inner-most repetition (second iteration)
4845 //
4946 // `index` is 1 because this is the second inner-most iteration
50- // `length ` is 2 because there are repetitions, "bar" and "baz"
47+ // `len ` is 2 because there are repetitions, "bar" and "baz"
5148 1 , 2 ,
52-
5349 // ## outer-most repetition (second iteration)
5450 //
5551 // `count` is 2 because of "bar" and "baz", i,e, `$l` has two repetitions,
5652 // `index` is 1 because this is the second outer-most iteration
57- // `length ` is 2 because there are 2 outer-most repetitions, ["foo"] and ["bar", "baz"]
53+ // `len ` is 2 because there are 2 outer-most repetitions, ["foo"] and ["bar", "baz"]
5854 2 , 1 , 2 ,
59-
6055 // # last count
6156
6257 // Because there are a total of 3 repetitions of `$l`, "foo", "bar" and "baz"
@@ -131,7 +126,6 @@ fn main() {
131126 & [ 2 ] [ ..] ,
132127 // t u v w x y z
133128 & [ 7 ] [ ..] ,
134-
135129 // (a b c) (d e f)
136130 & [ 6 , 2 ] [ ..] ,
137131 // (g h) (i j k l m)
@@ -142,15 +136,13 @@ fn main() {
142136 & [ 5 , 3 ] [ ..] ,
143137 // (t u v w x y z)
144138 & [ 7 , 1 ] [ ..] ,
145-
146139 // [ (a b c) (d e f) ]
147140 // [ (g h) (i j k l m) ]
148141 // [ (n) ]
149142 & [ 14 , 5 , 3 ] [ ..] ,
150143 // [ (o) (p q) (r s) ]
151144 // [ (t u v w x y z) ]
152145 & [ 12 , 4 , 2 ] [ ..] ,
153-
154146 // {
155147 // [ (a b c) (d e f) ]
156148 // [ (g h) (i j k l m) ]
@@ -165,43 +157,43 @@ fn main() {
165157 ) ;
166158
167159 // Grouped from the outer-most to the inner-most
168- macro_rules! three_nested_length {
160+ macro_rules! three_nested_len {
169161 ( $( { $( [ $( ( $( $i: ident ) * ) ) * ] ) * } ) * ) => {
170162 & [
171163 $( $( $( $(
172164 & [
173- ${ ignore( $i) } ${ length ( 3 ) } ,
174- ${ ignore( $i) } ${ length ( 2 ) } ,
175- ${ ignore( $i) } ${ length ( 1 ) } ,
176- ${ ignore( $i) } ${ length ( 0 ) } ,
165+ ${ ignore( $i) } ${ len ( 3 ) } ,
166+ ${ ignore( $i) } ${ len ( 2 ) } ,
167+ ${ ignore( $i) } ${ len ( 1 ) } ,
168+ ${ ignore( $i) } ${ len ( 0 ) } ,
177169 ] [ ..] ,
178170 ) * ) * ) * ) *
179171
180172 $( $( $(
181173 & [
182- ${ ignore( $i) } ${ length ( 2 ) } ,
183- ${ ignore( $i) } ${ length ( 1 ) } ,
184- ${ ignore( $i) } ${ length ( 0 ) } ,
174+ ${ ignore( $i) } ${ len ( 2 ) } ,
175+ ${ ignore( $i) } ${ len ( 1 ) } ,
176+ ${ ignore( $i) } ${ len ( 0 ) } ,
185177 ] [ ..] ,
186178 ) * ) * ) *
187179
188180 $( $(
189181 & [
190- ${ ignore( $i) } ${ length ( 1 ) } ,
191- ${ ignore( $i) } ${ length ( 0 ) } ,
182+ ${ ignore( $i) } ${ len ( 1 ) } ,
183+ ${ ignore( $i) } ${ len ( 0 ) } ,
192184 ] [ ..] ,
193185 ) * ) *
194186
195187 $(
196188 & [
197- ${ ignore( $i) } ${ length ( 0 ) } ,
189+ ${ ignore( $i) } ${ len ( 0 ) } ,
198190 ] [ ..] ,
199191 ) *
200192 ] [ ..]
201193 }
202194 }
203195 assert_eq ! (
204- three_nested_length !(
196+ three_nested_len !(
205197 {
206198 [ ( a b c) ( d e f) ]
207199 [ ( g h) ( i j k l m) ]
@@ -214,45 +206,64 @@ fn main() {
214206 ) ,
215207 & [
216208 // a b c
217- & [ 2 , 3 , 2 , 3 ] [ ..] , & [ 2 , 3 , 2 , 3 ] [ ..] , & [ 2 , 3 , 2 , 3 ] [ ..] ,
209+ & [ 2 , 3 , 2 , 3 ] [ ..] ,
210+ & [ 2 , 3 , 2 , 3 ] [ ..] ,
211+ & [ 2 , 3 , 2 , 3 ] [ ..] ,
218212 // d e f
219- & [ 2 , 3 , 2 , 3 ] [ ..] , & [ 2 , 3 , 2 , 3 ] [ ..] , & [ 2 , 3 , 2 , 3 ] [ ..] ,
213+ & [ 2 , 3 , 2 , 3 ] [ ..] ,
214+ & [ 2 , 3 , 2 , 3 ] [ ..] ,
215+ & [ 2 , 3 , 2 , 3 ] [ ..] ,
220216 // g h
221- & [ 2 , 3 , 2 , 2 ] [ ..] , & [ 2 , 3 , 2 , 2 ] [ ..] ,
217+ & [ 2 , 3 , 2 , 2 ] [ ..] ,
218+ & [ 2 , 3 , 2 , 2 ] [ ..] ,
222219 // i j k l m
223- & [ 2 , 3 , 2 , 5 ] [ ..] , & [ 2 , 3 , 2 , 5 ] [ ..] , & [ 2 , 3 , 2 , 5 ] [ ..] , & [ 2 , 3 , 2 , 5 ] [ ..] ,
220+ & [ 2 , 3 , 2 , 5 ] [ ..] ,
221+ & [ 2 , 3 , 2 , 5 ] [ ..] ,
222+ & [ 2 , 3 , 2 , 5 ] [ ..] ,
223+ & [ 2 , 3 , 2 , 5 ] [ ..] ,
224224 & [ 2 , 3 , 2 , 5 ] [ ..] ,
225225 // n
226226 & [ 2 , 3 , 1 , 1 ] [ ..] ,
227227 // o
228228 & [ 2 , 2 , 3 , 1 ] [ ..] ,
229229 // p q
230- & [ 2 , 2 , 3 , 2 ] [ ..] , & [ 2 , 2 , 3 , 2 ] [ ..] ,
230+ & [ 2 , 2 , 3 , 2 ] [ ..] ,
231+ & [ 2 , 2 , 3 , 2 ] [ ..] ,
231232 // r s
232- & [ 2 , 2 , 3 , 2 ] [ ..] , & [ 2 , 2 , 3 , 2 ] [ ..] ,
233+ & [ 2 , 2 , 3 , 2 ] [ ..] ,
234+ & [ 2 , 2 , 3 , 2 ] [ ..] ,
233235 // t u v w x y z
234- & [ 2 , 2 , 1 , 7 ] [ ..] , & [ 2 , 2 , 1 , 7 ] [ ..] , & [ 2 , 2 , 1 , 7 ] [ ..] , & [ 2 , 2 , 1 , 7 ] [ ..] ,
235- & [ 2 , 2 , 1 , 7 ] [ ..] , & [ 2 , 2 , 1 , 7 ] [ ..] , & [ 2 , 2 , 1 , 7 ] [ ..] ,
236-
236+ & [ 2 , 2 , 1 , 7 ] [ ..] ,
237+ & [ 2 , 2 , 1 , 7 ] [ ..] ,
238+ & [ 2 , 2 , 1 , 7 ] [ ..] ,
239+ & [ 2 , 2 , 1 , 7 ] [ ..] ,
240+ & [ 2 , 2 , 1 , 7 ] [ ..] ,
241+ & [ 2 , 2 , 1 , 7 ] [ ..] ,
242+ & [ 2 , 2 , 1 , 7 ] [ ..] ,
237243 // (a b c) (d e f)
238- & [ 2 , 3 , 2 ] [ ..] , & [ 2 , 3 , 2 ] [ ..] ,
244+ & [ 2 , 3 , 2 ] [ ..] ,
245+ & [ 2 , 3 , 2 ] [ ..] ,
239246 // (g h) (i j k l m)
240- & [ 2 , 3 , 2 ] [ ..] , & [ 2 , 3 , 2 ] [ ..] ,
247+ & [ 2 , 3 , 2 ] [ ..] ,
248+ & [ 2 , 3 , 2 ] [ ..] ,
241249 // (n)
242250 & [ 2 , 3 , 1 ] [ ..] ,
243251 // (o) (p q) (r s)
244- & [ 2 , 2 , 3 ] [ ..] , & [ 2 , 2 , 3 ] [ ..] , & [ 2 , 2 , 3 ] [ ..] ,
252+ & [ 2 , 2 , 3 ] [ ..] ,
253+ & [ 2 , 2 , 3 ] [ ..] ,
254+ & [ 2 , 2 , 3 ] [ ..] ,
245255 // (t u v w x y z)
246256 & [ 2 , 2 , 1 ] [ ..] ,
247-
248257 // [ (a b c) (d e f) ]
249258 // [ (g h) (i j k l m) ]
250259 // [ (n) ]
251- & [ 2 , 3 ] [ ..] , & [ 2 , 3 ] [ ..] , & [ 2 , 3 , ] [ ..] ,
260+ & [ 2 , 3 ] [ ..] ,
261+ & [ 2 , 3 ] [ ..] ,
262+ & [ 2 , 3 , ] [ ..] ,
252263 // [ (o) (p q) (r s) ]
253264 // [ (t u v w x y z) ]
254- & [ 2 , 2 ] [ ..] , & [ 2 , 2 ] [ .. ] ,
255-
265+ & [ 2 , 2 ] [ ..] ,
266+ & [ 2 , 2 ] [ .. ] ,
256267 // {
257268 // [ (a b c) (d e f) ]
258269 // [ (g h) (i j k l m) ]
@@ -262,10 +273,11 @@ fn main() {
262273 // [ (o) (p q) (r s) ]
263274 // [ (t u v w x y z) ]
264275 // }
265- & [ 2 ] [ ..] , & [ 2 ] [ ..]
276+ & [ 2 ] [ ..] ,
277+ & [ 2 ] [ ..]
266278 ] [ ..]
267279 ) ;
268280
269- // It is possible to say, to some degree, that count is an "amalgamation" of length (see
270- // each length line result and compare them with the count results)
281+ // It is possible to say, to some degree, that count is an "amalgamation" of len (see
282+ // each len line result and compare them with the count results)
271283}
0 commit comments