@@ -161,7 +161,7 @@ instead of `*` to mean "at least one".
161161# let input_1 = T::SpecialA(0);
162162# let input_2 = T::SpecialA(0);
163163macro_rules! early_return {
164- ($inp:expr, [ $($sp:path)| + ]) => (
164+ ($inp:expr, [ $($sp:path), + ]) => (
165165 match $inp {
166166 $(
167167 $sp(x) => { return x; }
@@ -171,7 +171,7 @@ macro_rules! early_return {
171171 )
172172}
173173// ...
174- early_return!(input_1, [T::SpecialA| T::SpecialC| T::SpecialD]);
174+ early_return!(input_1, [T::SpecialA, T::SpecialC, T::SpecialD]);
175175// ...
176176early_return!(input_2, [T::SpecialB]);
177177# return 0;
@@ -245,7 +245,7 @@ can solve the problem:
245245~~~~
246246macro_rules! biased_match {
247247 // special case: `let (x) = ...` is illegal, so use `let x = ...` instead
248- ( ($e:expr) ~ ($p:pat) else $err:stmt ;
248+ ( ($e:expr) -> ($p:pat) else $err:stmt ;
249249 binds $bind_res:ident
250250 ) => (
251251 let $bind_res = match $e {
@@ -254,7 +254,7 @@ macro_rules! biased_match {
254254 };
255255 );
256256 // more than one name; use a tuple
257- ( ($e:expr) ~ ($p:pat) else $err:stmt ;
257+ ( ($e:expr) -> ($p:pat) else $err:stmt ;
258258 binds $( $bind_res:ident ),*
259259 ) => (
260260 let ( $( $bind_res ),* ) = match $e {
@@ -268,9 +268,9 @@ macro_rules! biased_match {
268268# struct T2 { body: T3 }
269269# enum T3 { Good2(uint), Bad2}
270270# fn f(x: T1) -> uint {
271- biased_match!((x) ~ (T1::Good1(g1, val)) else { return 0 };
271+ biased_match!((x) -> (T1::Good1(g1, val)) else { return 0 };
272272 binds g1, val );
273- biased_match!((g1.body) ~ (T3::Good2(result) )
273+ biased_match!((g1.body) -> (T3::Good2(result) )
274274 else { panic!("Didn't get good_2") };
275275 binds result );
276276// complicated stuff goes here
@@ -286,7 +286,7 @@ pattern we want is clear:
286286~~~~
287287# fn main() {}
288288# macro_rules! b {
289- ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
289+ ( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
290290 binds $( $bind_res:ident ),*
291291 )
292292# => (0) }
@@ -317,8 +317,8 @@ input patterns:
317317~~~~
318318# fn main() {}
319319# macro_rules! b {
320- ( ($e :expr) ~ ($p :pat) else $err :stmt ;
321- $( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
320+ ( ($e :expr) -> ($p :pat) else $err :stmt ;
321+ $( ($e_rest:expr) -> ($p_rest:pat) else $err_rest:stmt ; )*
322322 binds $( $bind_res:ident ),*
323323 )
324324# => (0) }
@@ -333,14 +333,14 @@ piece of syntax (the `let`) which we only want to transcribe once.
333333
334334macro_rules! biased_match_rec {
335335 // Handle the first layer
336- ( ($e :expr) ~ ($p :pat) else $err :stmt ;
337- $( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
336+ ( ($e :expr) -> ($p :pat) else $err :stmt ;
337+ $( ($e_rest:expr) -> ($p_rest:pat) else $err_rest:stmt ; )*
338338 binds $( $bind_res:ident ),*
339339 ) => (
340340 match $e {
341341 $p => {
342342 // Recursively handle the next layer
343- biased_match_rec!($( ($e_rest) ~ ($p_rest) else $err_rest ; )*
343+ biased_match_rec!($( ($e_rest) -> ($p_rest) else $err_rest ; )*
344344 binds $( $bind_res ),*
345345 )
346346 }
@@ -354,20 +354,20 @@ macro_rules! biased_match_rec {
354354// Wrap the whole thing in a `let`.
355355macro_rules! biased_match {
356356 // special case: `let (x) = ...` is illegal, so use `let x = ...` instead
357- ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
357+ ( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
358358 binds $bind_res:ident
359359 ) => (
360360 let $bind_res = biased_match_rec!(
361- $( ($e) ~ ($p) else $err ; )*
361+ $( ($e) -> ($p) else $err ; )*
362362 binds $bind_res
363363 );
364364 );
365365 // more than one name: use a tuple
366- ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
366+ ( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
367367 binds $( $bind_res:ident ),*
368368 ) => (
369369 let ( $( $bind_res ),* ) = biased_match_rec!(
370- $( ($e) ~ ($p) else $err ; )*
370+ $( ($e) -> ($p) else $err ; )*
371371 binds $( $bind_res ),*
372372 );
373373 )
@@ -379,8 +379,8 @@ macro_rules! biased_match {
379379# enum T3 { Good2(uint), Bad2}
380380# fn f(x: T1) -> uint {
381381biased_match!(
382- (x) ~ (T1::Good1(g1, val)) else { return 0 };
383- (g1.body) ~ (T3::Good2(result) ) else { panic!("Didn't get Good2") };
382+ (x) -> (T1::Good1(g1, val)) else { return 0 };
383+ (g1.body) -> (T3::Good2(result) ) else { panic!("Didn't get Good2") };
384384 binds val, result );
385385// complicated stuff goes here
386386return result + val;
0 commit comments