We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8b44bdc + 6a75e70 commit 6f0e270Copy full SHA for 6f0e270
src/flow_control/match/binding.md
@@ -37,7 +37,10 @@ fn main() {
37
}
38
```
39
40
+<!--
41
You can also use binding to "destructure" `enum` variants, such as `Option`:
42
+-->
43
+`Option`のような、`enum`の値をデストラクトするためにも、バインディングを利用できます。
44
45
```rust,editable
46
fn some_number() -> Option<u32> {
@@ -48,10 +51,13 @@ fn main() {
48
51
match some_number() {
49
52
// Got `Some` variant, match if its value, bound to `n`,
50
53
// is equal to 42.
54
+ // `n`にバインドされた`Some`の値が42に等しいときにマッチ。
55
Some(n @ 42) => println!("The Answer: {}!", n),
56
// Match any other number.
57
+ // それ以外の数値にマッチ。
58
Some(n) => println!("Not interesting... {}", n),
59
// Match anything else (`None` variant).
60
+ // それ以外にマッチ(`None`の値)。
61
_ => (),
62
63
0 commit comments