Skip to content

Commit 6556204

Browse files
committed
added an example for binding after @
1 parent 5aa457b commit 6556204

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/patterns.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ match slice {
384384
// `end` is a slice of everything but the first element, which must be "a".
385385
["a", end @ ..] => println!("ends with: {:?}", end),
386386

387+
// 'whole' is the entire slice and `last` the the final element
388+
whole @ [.., last] => println!("the last element of {:?} is {}", whole, last)
389+
387390
rest => println!("{:?}", rest),
388391
}
389392

0 commit comments

Comments
 (0)