You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, the match arm can contain code that performs the deconstruction.
72
-
For example, the tuple `x` of type `(u16, u16)` can be deconstructed into two integers `y` and `z` of type `u16`.
70
+
This is more concise than including code to perform the deconstruction inside the match arm.
71
+
For example, the code above is a more concise alternative to this version that subsequently deconstructes the tuple `x` of type `(u16, u16)` into two integers `y` and `z` of type `u16`.
73
72
74
73
```rust
75
74
letunwrap_or_default:u32=matchSome((4, 2)) {
@@ -93,3 +92,9 @@ let unwrap_or_default: u32 = match Some(Left(42)) {
93
92
},
94
93
};
95
94
```
95
+
96
+
## Only two branches per `match`
97
+
98
+
Differently from Rust, the `match` expression only allows two match arms (branches) per `match`.
99
+
For example, it is currently not possible to match `Left(Left(x: u8))`, `Left(Right(x: u8)`, `Right(Left(x: u8))`, and `Right(Right(x: u8))` as arms of a single `match` expression.
100
+
Matching these four possibilities instead requires two nested `match` expressions.
0 commit comments