@@ -161,7 +161,7 @@ instead of `*` to mean "at least one".
161
161
# let input_1 = T::SpecialA(0);
162
162
# let input_2 = T::SpecialA(0);
163
163
macro_rules! early_return {
164
- ($inp:expr, [ $($sp:path)| + ]) => (
164
+ ($inp:expr, [ $($sp:path), + ]) => (
165
165
match $inp {
166
166
$(
167
167
$sp(x) => { return x; }
@@ -171,7 +171,7 @@ macro_rules! early_return {
171
171
)
172
172
}
173
173
// ...
174
- early_return!(input_1, [T::SpecialA| T::SpecialC| T::SpecialD]);
174
+ early_return!(input_1, [T::SpecialA, T::SpecialC, T::SpecialD]);
175
175
// ...
176
176
early_return!(input_2, [T::SpecialB]);
177
177
# return 0;
@@ -245,7 +245,7 @@ can solve the problem:
245
245
~~~~
246
246
macro_rules! biased_match {
247
247
// 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 ;
249
249
binds $bind_res:ident
250
250
) => (
251
251
let $bind_res = match $e {
@@ -254,7 +254,7 @@ macro_rules! biased_match {
254
254
};
255
255
);
256
256
// more than one name; use a tuple
257
- ( ($e:expr) ~ ($p:pat) else $err:stmt ;
257
+ ( ($e:expr) -> ($p:pat) else $err:stmt ;
258
258
binds $( $bind_res:ident ),*
259
259
) => (
260
260
let ( $( $bind_res ),* ) = match $e {
@@ -268,9 +268,9 @@ macro_rules! biased_match {
268
268
# struct T2 { body: T3 }
269
269
# enum T3 { Good2(uint), Bad2}
270
270
# 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 };
272
272
binds g1, val );
273
- biased_match!((g1.body) ~ (T3::Good2(result) )
273
+ biased_match!((g1.body) -> (T3::Good2(result) )
274
274
else { panic!("Didn't get good_2") };
275
275
binds result );
276
276
// complicated stuff goes here
@@ -286,7 +286,7 @@ pattern we want is clear:
286
286
~~~~
287
287
# fn main() {}
288
288
# macro_rules! b {
289
- ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
289
+ ( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
290
290
binds $( $bind_res:ident ),*
291
291
)
292
292
# => (0) }
@@ -317,8 +317,8 @@ input patterns:
317
317
~~~~
318
318
# fn main() {}
319
319
# 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 ; )*
322
322
binds $( $bind_res:ident ),*
323
323
)
324
324
# => (0) }
@@ -333,14 +333,14 @@ piece of syntax (the `let`) which we only want to transcribe once.
333
333
334
334
macro_rules! biased_match_rec {
335
335
// 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 ; )*
338
338
binds $( $bind_res:ident ),*
339
339
) => (
340
340
match $e {
341
341
$p => {
342
342
// 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 ; )*
344
344
binds $( $bind_res ),*
345
345
)
346
346
}
@@ -354,20 +354,20 @@ macro_rules! biased_match_rec {
354
354
// Wrap the whole thing in a `let`.
355
355
macro_rules! biased_match {
356
356
// 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 ; )*
358
358
binds $bind_res:ident
359
359
) => (
360
360
let $bind_res = biased_match_rec!(
361
- $( ($e) ~ ($p) else $err ; )*
361
+ $( ($e) -> ($p) else $err ; )*
362
362
binds $bind_res
363
363
);
364
364
);
365
365
// more than one name: use a tuple
366
- ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
366
+ ( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
367
367
binds $( $bind_res:ident ),*
368
368
) => (
369
369
let ( $( $bind_res ),* ) = biased_match_rec!(
370
- $( ($e) ~ ($p) else $err ; )*
370
+ $( ($e) -> ($p) else $err ; )*
371
371
binds $( $bind_res ),*
372
372
);
373
373
)
@@ -379,8 +379,8 @@ macro_rules! biased_match {
379
379
# enum T3 { Good2(uint), Bad2}
380
380
# fn f(x: T1) -> uint {
381
381
biased_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") };
384
384
binds val, result );
385
385
// complicated stuff goes here
386
386
return result + val;
0 commit comments