trpl-zh-cn/listings/ch06-enums-and-pattern-matching/no-listing-10-non-exhaustive-match/src/main.rs
2022-02-06 16:43:51 +08:00

14 lines
263 B
Rust
Executable File

fn main() {
// ANCHOR: here
fn plus_one(x: Option<i32>) -> Option<i32> {
match x {
Some(i) => Some(i + 1),
}
}
// ANCHOR_END: here
let five = Some(5);
let six = plus_one(five);
let none = plus_one(None);
}