1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-10-09 10:55:26 +02:00

docs: improve language in control-flow-basics section (#2887)

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 18:49:57 +02:00
committed by GitHub
parent 513c450e7c
commit 041fa6b9c2
6 changed files with 8 additions and 9 deletions

View File

@@ -4,9 +4,8 @@ minutes: 5
# Blocks and Scopes
A block in Rust contains a sequence of expressions, enclosed by braces `{}`.
Each block has a value and a type, which are those of the last expression of the
block:
A block in Rust contains a sequence of expressions, enclosed by braces {}. The
final expression of a block determines the value and type of the whole block:
```rust,editable
fn main() {

View File

@@ -30,7 +30,7 @@ fn main() {
<details>
Note that `loop` is the only looping construct which can return a non-trivial
Note that `loop` is the only looping construct that can return a non-trivial
value. This is because it's guaranteed to only return at a `break` statement
(unlike `while` and `for` loops, which can also return when the condition
fails).

View File

@@ -1,7 +1,7 @@
# Labels
Both `continue` and `break` can optionally take a label argument which is used
to break out of nested loops:
Both `continue` and `break` can optionally take a label argument that is used to
break out of nested loops:
```rust,editable
fn main() {

View File

@@ -22,7 +22,7 @@ For example, beginning with _n<sub>1</sub>_ = 3:
- 2 is even, so _n<sub>8</sub>_ = 1; and
- the sequence terminates.
Write a function to calculate the length of the collatz sequence for a given
Write a function to calculate the length of the Collatz sequence for a given
initial `n`.
```rust,editable,should_panic

View File

@@ -19,6 +19,6 @@ fn main() {
<details>
- The `loop` statement works like a `while true` loop. Use it for things like
servers which will serve connections forever.
servers that will serve connections forever.
</details>

View File

@@ -59,7 +59,7 @@ fn main() {
## More to Explore
- To further motivate the usage of `match`, you can compare the examples to
their equivalents written with `if`. In the second case matching on a `bool`
their equivalents written with `if`. In the second case, matching on a `bool`,
an `if {} else {}` block is pretty similar. But in the first example that
checks multiple cases, a `match` expression can be more concise than
`if {} else if {} else if {} else`.