Skip to content

Commit

Permalink
I'm gonna call it the WTF pattern binding. Fixes #148.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfbiedert committed Oct 22, 2021
1 parent 6e8b3dd commit 64afec1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ Constructs found in `match` or `let` expressions, or function parameters.
| {{ tab() }} `let (a, ..) = abc;` | Ignoring 'the rest' also works. |
| {{ tab() }} `let (.., a, b) = (1, 2);` | Specific bindings take precedence over 'the rest', here `a` is `1`, `b` is `2`. |
| {{ tab() }} `let s @ S { x } = get();` | Bind `s` to `S` while `x` is bound to `s.x`, **pattern binding**, {{ book(page="ch18-03-pattern-syntax.html#-bindings") }} {{ ex(page="flow_control/match/binding.html#binding") }} {{ ref(page="patterns.html#identifier-patterns") }} _c_. below {{ esoteric() }} |
| {{ tab() }} `let w @ t @ f = get();` | Stores 3 copies of `get()` result in each `w`, `t`, `f`. Please don't do this. {{ esoteric() }} |
| {{ tab() }} `let Some(x) = get();` | **Won't** work {{ bad() }} if pattern can be **refuted**, {{ ref(page="expressions/if-expr.html#if-let-expressions") }} use `if let` instead. |
| `if let Some(x) = get() {}` | Branch if pattern can be assigned (e.g., `enum` variant), syntactic sugar. <sup>*</sup>|
| `while let Some(x) = get() {}` | Equiv.; here keep calling `get()`, run `{}` as long as pattern can be assigned. |
Expand Down

0 comments on commit 64afec1

Please sign in to comment.