Auto merge of #32202 - arielb1:slice-patterns, r=nikomatsakis

Implement RFC495 semantics for slice patterns

non-MIR translation is still not supported for these and will happily ICE.

This is a [breaking-change] for many uses of slice_patterns.

[RFC 495 text](https://github.com/rust-lang/rfcs/blob/master/text/0495-array-pattern-changes.md)
This commit is contained in:
bors 2016-06-08 19:30:33 -07:00
commit bb4b3fb7f9
77 changed files with 940 additions and 738 deletions

View file

@ -10,7 +10,7 @@ fn main() {
let v = vec!["match_this", "1"];
match &v[..] {
["match_this", second] => println!("The second element is {}", second),
&["match_this", second] => println!("The second element is {}", second),
_ => {},
}
}
@ -26,8 +26,8 @@ slice will be bound to that name. For example:
fn is_symmetric(list: &[u32]) -> bool {
match list {
[] | [_] => true,
[x, inside.., y] if x == y => is_symmetric(inside),
&[] | &[_] => true,
&[x, ref inside.., y] if x == y => is_symmetric(inside),
_ => false
}
}