diff --git a/src/flow_control/match/guard.md b/src/flow_control/match/guard.md index 336b7f1233..9caa65aa00 100644 --- a/src/flow_control/match/guard.md +++ b/src/flow_control/match/guard.md @@ -18,6 +18,22 @@ fn main() { } ``` +Note that the compiler does not check arbitrary expressions for whether all +possible conditions have been checked. Therefore, you must use the `_` pattern +at the end. + +```rust,editable +fn main() { + let number: u8 = 4; + + match number { + i if i == 0 => println!("Zero"), + i if i > 0 => println!("Greater than zero"), + _ => println!("Fell through"), // This should not be possible to reach + } +} +``` + ### See also: [Tuples](../../primitives/tuples.md)