1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-09-16 09:36:41 +02:00

docs: improve language in closures section (#2888)

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).
This commit is contained in:
Martin Geisler
2025-09-06 18:41:25 +02:00
committed by GitHub
parent 93de441a6d
commit 513c450e7c
2 changed files with 4 additions and 4 deletions

View File

@@ -4,8 +4,8 @@ minutes: 10
# Exercise: Log Filter
Building on the generic logger from this morning, implement a `Filter` which
uses a closure to filter log messages, sending those which pass the filtering
Building on the generic logger from this morning, implement a `Filter` that uses
a closure to filter log messages, sending those that pass the filtering
predicate to an inner logger.
```rust,compile_fail,editable

View File

@@ -4,7 +4,7 @@ minutes: 10
# Closure traits
Closures or lambda expressions have types which cannot be named. However, they
Closures or lambda expressions have types that cannot be named. However, they
implement special [`Fn`](https://doc.rust-lang.org/std/ops/trait.Fn.html),
[`FnMut`](https://doc.rust-lang.org/std/ops/trait.FnMut.html), and
[`FnOnce`](https://doc.rust-lang.org/std/ops/trait.FnOnce.html) traits:
@@ -67,7 +67,7 @@ can (i.e. you call it once), or `FnMut` else, and last `Fn`. This allows the
most flexibility for the caller.
In contrast, when you have a closure, the most flexible you can have is `Fn`
(which can be passed to a consumer of any of the 3 closure traits), then
(which can be passed to a consumer of any of the three closure traits), then
`FnMut`, and lastly `FnOnce`.
The compiler also infers `Copy` (e.g. for `add_suffix`) and `Clone` (e.g.