You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-27 19:18:59 +02:00
@ -10,7 +10,7 @@ You can define richer enums where the variants carry data. You can then use the
|
|||||||
<details>
|
<details>
|
||||||
|
|
||||||
* The values in the enum variants can only be accessed after being pattern matched. The pattern binds references to the fields in the "match arm" after the `=>`.
|
* The values in the enum variants can only be accessed after being pattern matched. The pattern binds references to the fields in the "match arm" after the `=>`.
|
||||||
* The expressions is matched against the patterns from top to bottom. There is no fall-through like in C or C++.
|
* The expression is matched against the patterns from top to bottom. There is no fall-through like in C or C++.
|
||||||
* The match expression has a value. The value is the last expression in the match arm which was executed.
|
* The match expression has a value. The value is the last expression in the match arm which was executed.
|
||||||
* Starting from the top we look for what pattern matches the value then run the code following the arrow. Once we find a match, we stop.
|
* Starting from the top we look for what pattern matches the value then run the code following the arrow. Once we find a match, we stop.
|
||||||
* Demonstrate what happens when the search is inexhaustive. Note the advantage the Rust compiler provides by confirming when all cases are handled.
|
* Demonstrate what happens when the search is inexhaustive. Note the advantage the Rust compiler provides by confirming when all cases are handled.
|
||||||
|
Reference in New Issue
Block a user