rust/src/doc/trpl/slice-patterns.md
Steve Klabnik b577beeb3a copyedits: patterns
This also puts slice patterns in nightly docs, where they belong.
2015-04-10 12:26:58 -04:00

333 B

% Slice patterns

If you want to match against a slice or array, you can use & with the slice_patterns feature:

#![feature(slice_patterns)]

fn main() {
    let v = vec!["match_this", "1"];

    match &v[..] {
        ["match_this", second] => println!("The second element is {}", second),
        _ => {},
    }
}