@@ -22,15 +22,15 @@ doing nothing otherwise:
22
22
~~~~
23
23
# enum T { SpecialA(uint), SpecialB(uint) }
24
24
# fn f() -> uint {
25
- # let input_1 = SpecialA(0);
26
- # let input_2 = SpecialA(0);
25
+ # let input_1 = T:: SpecialA(0);
26
+ # let input_2 = T:: SpecialA(0);
27
27
match input_1 {
28
- SpecialA(x) => { return x; }
28
+ T:: SpecialA(x) => { return x; }
29
29
_ => {}
30
30
}
31
31
// ...
32
32
match input_2 {
33
- SpecialB(x) => { return x; }
33
+ T:: SpecialB(x) => { return x; }
34
34
_ => {}
35
35
}
36
36
# return 0u;
@@ -49,20 +49,20 @@ the pattern in the above code:
49
49
# #![feature(macro_rules)]
50
50
# enum T { SpecialA(uint), SpecialB(uint) }
51
51
# fn f() -> uint {
52
- # let input_1 = SpecialA(0);
53
- # let input_2 = SpecialA(0);
52
+ # let input_1 = T:: SpecialA(0);
53
+ # let input_2 = T:: SpecialA(0);
54
54
macro_rules! early_return(
55
- ($inp:expr $sp:ident ) => ( // invoke it like `(input_5 SpecialE)`
55
+ ($inp:expr $sp:path ) => ( // invoke it like `(input_5 SpecialE)`
56
56
match $inp {
57
57
$sp(x) => { return x; }
58
58
_ => {}
59
59
}
60
60
);
61
61
)
62
62
// ...
63
- early_return!(input_1 SpecialA);
63
+ early_return!(input_1 T:: SpecialA);
64
64
// ...
65
- early_return!(input_2 SpecialB);
65
+ early_return!(input_2 T:: SpecialB);
66
66
# return 0;
67
67
# }
68
68
# fn main() {}
@@ -169,10 +169,10 @@ instead of `*` to mean "at least one".
169
169
# #![feature(macro_rules)]
170
170
# enum T { SpecialA(uint),SpecialB(uint),SpecialC(uint),SpecialD(uint)}
171
171
# fn f() -> uint {
172
- # let input_1 = SpecialA(0);
173
- # let input_2 = SpecialA(0);
172
+ # let input_1 = T:: SpecialA(0);
173
+ # let input_2 = T:: SpecialA(0);
174
174
macro_rules! early_return(
175
- ($inp:expr, [ $($sp:ident )|+ ]) => (
175
+ ($inp:expr, [ $($sp:path )|+ ]) => (
176
176
match $inp {
177
177
$(
178
178
$sp(x) => { return x; }
@@ -182,9 +182,9 @@ macro_rules! early_return(
182
182
);
183
183
)
184
184
// ...
185
- early_return!(input_1, [SpecialA|SpecialC|SpecialD]);
185
+ early_return!(input_1, [T:: SpecialA|T:: SpecialC|T:: SpecialD]);
186
186
// ...
187
- early_return!(input_2, [SpecialB]);
187
+ early_return!(input_2, [T:: SpecialB]);
188
188
# return 0;
189
189
# }
190
190
# fn main() {}
@@ -234,9 +234,9 @@ Now consider code like the following:
234
234
# enum T3 { Good2(uint), Bad2}
235
235
# fn f(x: T1) -> uint {
236
236
match x {
237
- Good1(g1, val) => {
237
+ T1:: Good1(g1, val) => {
238
238
match g1.body {
239
- Good2(result) => {
239
+ T3:: Good2(result) => {
240
240
// complicated stuff goes here
241
241
return result + val;
242
242
},
@@ -281,9 +281,9 @@ macro_rules! biased_match (
281
281
# struct T2 { body: T3 }
282
282
# enum T3 { Good2(uint), Bad2}
283
283
# fn f(x: T1) -> uint {
284
- biased_match!((x) ~ (Good1(g1, val)) else { return 0 };
284
+ biased_match!((x) ~ (T1:: Good1(g1, val)) else { return 0 };
285
285
binds g1, val )
286
- biased_match!((g1.body) ~ (Good2(result) )
286
+ biased_match!((g1.body) ~ (T3:: Good2(result) )
287
287
else { panic!("Didn't get good_2") };
288
288
binds result )
289
289
// complicated stuff goes here
@@ -396,8 +396,8 @@ macro_rules! biased_match (
396
396
# enum T3 { Good2(uint), Bad2}
397
397
# fn f(x: T1) -> uint {
398
398
biased_match!(
399
- (x) ~ (Good1(g1, val)) else { return 0 };
400
- (g1.body) ~ (Good2(result) ) else { panic!("Didn't get Good2") };
399
+ (x) ~ (T1:: Good1(g1, val)) else { return 0 };
400
+ (g1.body) ~ (T3:: Good2(result) ) else { panic!("Didn't get Good2") };
401
401
binds val, result )
402
402
// complicated stuff goes here
403
403
return result + val;
0 commit comments