mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-01-05 16:10:31 +02:00
Update match-guards.md
This commit is contained in:
parent
a0a1059c0d
commit
4588d95427
@ -9,11 +9,10 @@ expression which will be executed if the pattern matches:
|
||||
|
||||
<details>
|
||||
|
||||
Match guards as a separate syntax feature are important and necessary. They are not
|
||||
the same as separate `if` expression inside of the match arm.
|
||||
|
||||
An `if` expression inside of the branch block (after `=>`) happens after the match arm
|
||||
is selected. Failing the `if` condition inside of that block won't result in other arms
|
||||
of the original `match` expression being considered.
|
||||
|
||||
Key Points:
|
||||
* Match guards as a separate syntax feature are important and necessary.
|
||||
* They are not the same as separate `if` expression inside of the match arm. An `if` expression inside of the branch block (after `=>`) happens after the match arm is selected. Failing the `if` condition inside of that block won't result in other arms
|
||||
of the original `match` expression being considered.
|
||||
* You can use the variables defined in the pattern in your if expression.
|
||||
* The condition defined in the guard applies to every expression in a pattern with an `|`.
|
||||
</details>
|
||||
|
Loading…
Reference in New Issue
Block a user