]> git.proxmox.com Git - rustc.git/blobdiff - src/doc/rust-by-example/src/flow_control/match.md
New upstream version 1.50.0+dfsg1
[rustc.git] / src / doc / rust-by-example / src / flow_control / match.md
index 02a80670ffe1017968b16b6028f8198b3d4b554c..6beeea36683e9cee799255adbe73770559609dfb 100644 (file)
@@ -1,7 +1,8 @@
 # match
 
 Rust provides pattern matching via the `match` keyword, which can be used like
-a C `switch`.
+a C `switch`. The first matching arm is evaluated and all possible values must be
+covered.
 
 ```rust,editable
 fn main() {
@@ -14,10 +15,12 @@ fn main() {
         1 => println!("One!"),
         // Match several values
         2 | 3 | 5 | 7 | 11 => println!("This is a prime"),
+        // TODO ^ Try adding 13 to the list of prime values
         // Match an inclusive range
         13..=19 => println!("A teen"),
         // Handle the rest of cases
         _ => println!("Ain't special"),
+        // TODO ^ Try commenting out this catch-all arm
     }
 
     let boolean = true;