trpl-zh-cn/listings/ch19-patterns-and-matching/listing-19-26/src/main.rs

12 lines
247 B
Rust
Raw Normal View History

2022-02-06 16:43:51 +08:00
fn main() {
// ANCHOR: here
let num = Some(4);
match num {
Some(x) if x % 2 == 0 => println!("The number {x} is even"),
Some(x) => println!("The number {x} is odd"),
2022-02-06 16:43:51 +08:00
None => (),
}
// ANCHOR_END: here
}