Skip to content

Commit

Permalink
Fixes #84 and added more links.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfbiedert committed Feb 2, 2020
1 parent c20941e commit d37693f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,16 @@ Pattern matching arms in `match` expressions. The left side of these arms can al
| `D => {}` | Match enum variant `E::D` if `D` in `use`. |
| `D => {}` | Match anything, bind `D`; possibly false friend {{ bad() }} of `E::D` if `D` not in `use`. |
| `_ => {}` | Proper wildcard that matches anything / "all the rest". |
| `[a, 0] => {}` | Match array with any value for `a` and `0` for second. |
| `(a, 0) => {}` | Match tuple with any value for `a` and `0` for second. |
| `x @ 1..=5 => {}` | Bind matched to `x`; **pattern binding**. {{ book(page="ch18-03-pattern-syntax.html#-bindings") }} {{ ex(page="flow_control/match/binding.html#binding") }} |
| `[a, 0] => {}` | **Slice pattern**, {{ ref(page="patterns.html?highlight=slice,pattern#slice-patterns") }} {{ link(url="https://doc.rust-lang.org/edition-guide/rust-2018/slice-patterns.html") }} match array with any value for `a` and `0` for second. |
| {{ tab() }} `[1, ..] => {}` | Match array starting with `1`, any value for rest; **subslice pattern**. {{ todo() }} |
| {{ tab() }} `[2, .., 5] => {}` | Match array starting with `1`, ending with `5`. |
| {{ tab() }} `[2, x @ .., 5] => {}` | Same, but also bind `x` to slice representing middle (_c._ next entry). |
| `x @ 1..=5 => {}` | Bind matched to `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") }} here `x` would be `1`, `2`, ... or `5`. |
| <code>0 &vert; 1 => {}</code> | Pattern alternatives (or-patterns).|
| {{ tab() }} <code>E::A &vert; E::Z </code> | Same, but on enum variants. |
| {{ tab() }} <code>E::C {x} &vert; E::D {x}</code> | Same, but bind `x` if all variants have it. |
| `S { x } if x > 10` | Pattern match **guards**. {{ book(page="ch18-03-pattern-syntax.html#extra-conditionals-with-match-guards")}} {{ ex(page="flow_control/match/guard.html#guards")}} |
| `S { x } if x > 10` | Pattern **match guards**, {{ book(page="ch18-03-pattern-syntax.html#extra-conditionals-with-match-guards")}} {{ ex(page="flow_control/match/guard.html#guards")}} {{ ref(page="expressions/match-expr.html#match-guards") }} condition must be true as well to match. |

</div>

Expand Down

0 comments on commit d37693f

Please sign in to comment.