diff --git a/src/patterns.md b/src/patterns.md index 7676d5255..43fde6e7a 100644 --- a/src/patterns.md +++ b/src/patterns.md @@ -384,6 +384,9 @@ match slice { // `end` is a slice of everything but the first element, which must be "a". ["a", end @ ..] => println!("ends with: {:?}", end), + // 'whole' is the entire slice and `last` is the final element + whole @ [.., last] => println!("the last element of {:?} is {}", whole, last), + rest => println!("{:?}", rest), }