@@ -22,15 +22,15 @@ doing nothing otherwise:
2222~~~~
2323# enum T { SpecialA(uint), SpecialB(uint) }
2424# 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);
2727match input_1 {
28- SpecialA(x) => { return x; }
28+ T:: SpecialA(x) => { return x; }
2929 _ => {}
3030}
3131// ...
3232match input_2 {
33- SpecialB(x) => { return x; }
33+ T:: SpecialB(x) => { return x; }
3434 _ => {}
3535}
3636# return 0u;
@@ -49,20 +49,20 @@ the pattern in the above code:
4949# #![feature(macro_rules)]
5050# enum T { SpecialA(uint), SpecialB(uint) }
5151# 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);
5454macro_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)`
5656 match $inp {
5757 $sp(x) => { return x; }
5858 _ => {}
5959 }
6060 );
6161)
6262// ...
63- early_return!(input_1 SpecialA);
63+ early_return!(input_1 T:: SpecialA);
6464// ...
65- early_return!(input_2 SpecialB);
65+ early_return!(input_2 T:: SpecialB);
6666# return 0;
6767# }
6868# fn main() {}
@@ -169,10 +169,10 @@ instead of `*` to mean "at least one".
169169# #![feature(macro_rules)]
170170# enum T { SpecialA(uint),SpecialB(uint),SpecialC(uint),SpecialD(uint)}
171171# 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);
174174macro_rules! early_return(
175- ($inp:expr, [ $($sp:ident )|+ ]) => (
175+ ($inp:expr, [ $($sp:path )|+ ]) => (
176176 match $inp {
177177 $(
178178 $sp(x) => { return x; }
@@ -182,9 +182,9 @@ macro_rules! early_return(
182182 );
183183)
184184// ...
185- early_return!(input_1, [SpecialA|SpecialC|SpecialD]);
185+ early_return!(input_1, [T:: SpecialA|T:: SpecialC|T:: SpecialD]);
186186// ...
187- early_return!(input_2, [SpecialB]);
187+ early_return!(input_2, [T:: SpecialB]);
188188# return 0;
189189# }
190190# fn main() {}
@@ -234,9 +234,9 @@ Now consider code like the following:
234234# enum T3 { Good2(uint), Bad2}
235235# fn f(x: T1) -> uint {
236236match x {
237- Good1(g1, val) => {
237+ T1:: Good1(g1, val) => {
238238 match g1.body {
239- Good2(result) => {
239+ T3:: Good2(result) => {
240240 // complicated stuff goes here
241241 return result + val;
242242 },
@@ -281,9 +281,9 @@ macro_rules! biased_match (
281281# struct T2 { body: T3 }
282282# enum T3 { Good2(uint), Bad2}
283283# 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 };
285285 binds g1, val )
286- biased_match!((g1.body) ~ (Good2(result) )
286+ biased_match!((g1.body) ~ (T3:: Good2(result) )
287287 else { panic!("Didn't get good_2") };
288288 binds result )
289289// complicated stuff goes here
@@ -396,8 +396,8 @@ macro_rules! biased_match (
396396# enum T3 { Good2(uint), Bad2}
397397# fn f(x: T1) -> uint {
398398biased_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") };
401401 binds val, result )
402402// complicated stuff goes here
403403return result + val;
0 commit comments