mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-01-20 21:18:26 +02:00
Speaker notes for pattern matching (#260)
* Speaker notes for pattern matching * Update pattern-matching.md Co-authored-by: Fabian Bornhofen <fbornhofen@google.com>
This commit is contained in:
parent
bd3642694b
commit
a517ff5816
@ -19,3 +19,17 @@ fn main() {
|
||||
```
|
||||
|
||||
The `_` pattern is a wildcard pattern which matches any value.
|
||||
|
||||
<details>
|
||||
|
||||
Key Points:
|
||||
* You might point out how some specific characters are being used when in a patten
|
||||
* `|` as an `or`
|
||||
* `..` can expand as much as it needs to be
|
||||
* `1..=5` represents an inclusive range
|
||||
* `_` is a wild card
|
||||
* It can be useful to show how binding works, by for instance replacing a wildcard character with a variable, or removing the quotes around `q`.
|
||||
* You can demonstrate matching on a reference.
|
||||
* This might be a good time to bring up the concept of irrefutable patterns, as the term can show up in error messages.
|
||||
|
||||
</details>
|
||||
|
Loading…
x
Reference in New Issue
Block a user