trpl-zh-cn/listings/ch18-patterns-and-matching/listing-18-26/src/main.rs
2023-01-16 17:34:52 +08:00

12 lines
251 B
Rust
Executable File

fn main() {
// ANCHOR: here
let num = Some(4);
match num {
Some(x) if x % 2 == 0 => println!("The number {} is even", x),
Some(x) => println!("The number {} is odd", x),
None => (),
}
// ANCHOR_END: here
}