mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-05-03 20:22:32 +08:00
14 lines
263 B
Rust
Executable File
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);
|
|
}
|