Skip to content

Commit 4fb790d

Browse files
committed
Add an example showing pattern binding when matching several values in a match arm
1 parent 2c9b490 commit 4fb790d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/flow_control/match/binding.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ fn main() {
2525
// Now the age can be reported.
2626
n @ 1 ..= 12 => println!("I'm a child of age {:?}", n),
2727
n @ 13 ..= 19 => println!("I'm a teen of age {:?}", n),
28+
// A similar binding can be done when matching several values.
29+
n @ (1 | 7 | 15 | 13) => println!("I'm a teen of age {:?}", n),
2830
// Nothing bound. Return the result.
2931
n => println!("I'm an old person of age {:?}", n),
3032
}

0 commit comments

Comments
 (0)