[Rust Guide] 18.3. Pattern Syntax
rust
dev.to
If you find this helpful, please like, bookmark, and follow. To keep learning along, follow this series. 18.3.1 Matching Literals Patterns can match literals directly. Take a look at this example: let x = 1; match x { 1 => println!("one"), 2 => println!("two"), 3 => println!("three"), _ => println!("anything"), } This code prints one because the value in x is 1. This syntax is very useful when you want the code to act on a specific value. 18.3.2 Ma