Skip to content

Commit d301b3a

Browse files
authored
Merge pull request #1395 from shreepads/patch-2
Clarify first matching arm and all possible values
2 parents ca83777 + 6dc57f4 commit d301b3a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/flow_control/match.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# match
22

33
Rust provides pattern matching via the `match` keyword, which can be used like
4-
a C `switch`.
4+
a C `switch`. The first matching arm is evaluated and all possible values must be
5+
covered.
56

67
```rust,editable
78
fn main() {
@@ -14,10 +15,12 @@ fn main() {
1415
1 => println!("One!"),
1516
// Match several values
1617
2 | 3 | 5 | 7 | 11 => println!("This is a prime"),
18+
// TODO ^ Try adding 13 to the list of prime values
1719
// Match an inclusive range
1820
13..=19 => println!("A teen"),
1921
// Handle the rest of cases
2022
_ => println!("Ain't special"),
23+
// TODO ^ Try commenting out this catch-all arm
2124
}
2225
2326
let boolean = true;

0 commit comments

Comments
 (0)