librustc: Change the syntax of subslice matching to use postfix ..
instead of prefix `..`.
This breaks code that looked like:
match foo {
[ first, ..middle, last ] => { ... }
}
Change this code to:
match foo {
[ first, middle.., last ] => { ... }
}
RFC #55.
Closes #16967.
[breaking-change]
This commit is contained in:
parent
6f34760e41
commit
eb678ff87f
26 changed files with 110 additions and 82 deletions
|
|
@ -3300,7 +3300,7 @@ it will bind the corresponding slice to the variable. Example:
|
|||
fn is_symmetric(list: &[uint]) -> bool {
|
||||
match list {
|
||||
[] | [_] => true,
|
||||
[x, ..inside, y] if x == y => is_symmetric(inside),
|
||||
[x, inside.., y] if x == y => is_symmetric(inside),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1707,7 +1707,7 @@ let score = match numbers {
|
|||
[] => 0,
|
||||
[a] => a * 10,
|
||||
[a, b] => a * 6 + b * 4,
|
||||
[a, b, c, ..rest] => a * 5 + b * 3 + c * 2 + rest.len() as int
|
||||
[a, b, c, rest..] => a * 5 + b * 3 + c * 2 + rest.len() as int
|
||||
};
|
||||
~~~~
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue