Skip to content

Commit 72c1139

Browse files
committed
Add match order example.
1 parent 9a88258 commit 72c1139

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/expressions/match-expr.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ let message = match x {
7474
};
7575

7676
assert_eq!(message, "a few");
77+
78+
// Demonstration of pattern match order.
79+
struct S(i32, i32);
80+
81+
match S(1, 2) {
82+
S(z @ 1, _) | S(_, z @ 2) => assert_eq!(z, 1),
83+
_ => panic!(),
84+
}
7785
```
7886

7987
> Note: The `2..=9` is a [Range Pattern], not a [Range Expression]. Thus, only

0 commit comments

Comments
 (0)