You've already forked comprehensive-rust
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:
@@ -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
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user