1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-12-21 06:31:06 +02:00

docs: improve language in pattern-matching section (#2879)

I asked Gemini to review the English for inconsistencies and grammar
mistakes. This is the result and I hope it's useful!

As a non-native speaker, it is hard for me to evaluate the finer
details, so let me know if you would like to see changes (or even
better: make them directly in the PR with the suggestion function).

---------

Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
This commit is contained in:
Martin Geisler
2025-09-06 19:11:58 +02:00
committed by GitHub
parent 2679581811
commit 7ebca876d2
6 changed files with 7 additions and 7 deletions

View File

@@ -4,7 +4,7 @@ minutes: 4
# Structs
Like tuples, Struct can also be destructured by matching:
Like tuples, structs can also be destructured by matching:
```rust,editable
{{#include ../../third_party/rust-by-example/destructuring-structs.rs}}

View File

@@ -22,7 +22,7 @@ to `30`. We can represent the expression as a tree:
```
A bigger and more complex expression would be `(10 * 9) + ((3 - 4) * 5)`, which
evaluate to `85`. We represent this as a much bigger tree:
evaluates to `85`. We represent this as a much bigger tree:
<!-- mdbook-xgettext: skip -->

View File

@@ -37,8 +37,8 @@ fn main() {
- Patterns are type-specific, including irrefutable patterns. Try adding or
removing an element to the tuple and look at the resulting compiler errors.
- Variable names are patterns that always match and which bind the matched value
into a new variable with that name.
- Variable names are patterns that always match and bind the matched value into
a new variable with that name.
- `_` is a pattern that always matches any value, discarding the matched value.

View File

@@ -4,7 +4,7 @@ minutes: 10
# Let Control Flow
Rust has a few control flow constructs which differ from other languages. They
Rust has a few control flow constructs that differ from other languages. They
are used for pattern matching:
- `if let` expressions

View File

@@ -2,7 +2,7 @@
Like with `if let`, there is a
[`while let`](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-pattern-loops)
variant which repeatedly tests a value against a pattern:
variant that repeatedly tests a value against a pattern:
```rust,editable
fn main() {

View File

@@ -35,7 +35,7 @@ Key Points:
- You might point out how some specific characters are being used when in a
pattern
- `|` as an `or`
- `..` can expand as much as it needs to be
- `..` matches any number of items
- `1..=5` represents an inclusive range
- `_` is a wild card