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