Skip to content

Commit ef5cddf

Browse files
authored
Add missing Rust example for control flow with optionality (#67)
1 parent d7408f0 commit ef5cddf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/language/nullability-and-optionality.md

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ if (max is { } someMax)
3636

3737
You can use pattern matching to achieve the same behavior in Rust:
3838

39+
```rust
40+
let max = Some(10u32);
41+
match max {
42+
Some(max) => println!("The maximum is {}.", max), // The maximum is 10.
43+
None => ()
44+
}
45+
```
46+
3947
It would even be more concise to use `if let`:
4048

4149
```rust

0 commit comments

Comments
 (0)