Skip to content

Fix ambiguous phrasing in 8.2.13 in paragraph on closure traits #991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/expressions/closure-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ A closure can be forced to capture its environment by copying or moving values b
This is often used to ensure that the closure's type is `'static`.

The compiler will determine which of the [closure traits](../types/closure.md#call-traits-and-coercions) the closure's type will implement by how it acts on its captured variables.
The closure will also implement [`Send`](../special-types-and-traits.md#send) and/or [`Sync`](../special-types-and-traits.md#sync) if all of its captured types do.
These traits allow functions to accept closures using generics, even though the exact types can't be named.
The closure will also implement the closure traits [`Send`](../special-types-and-traits.md#send) and/or [`Sync`](../special-types-and-traits.md#sync) if all of its captured types do.
Closure traits allow functions to accept closures using generics, even though the exact types can't be named.
Comment on lines +34 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't add "the closure traits" for Send/Sync. "Closure traits" specifically refers to Fn, FnMut, and FnOnce. The other traits that closures may implement (send/sync/copy/clone) are just extras, and are not directly related to allowing use as function parameters.

I'm not sure why they are even called closure traits, since they are just the general call traits which are used for things other than closures. And I also question why it explicitly says "using generics", since closures can also be passed as trait objects.

Since the closure type chapter uses a clearer term ("call traits"), I would change it to use that phrasing, and change the last sentence to something like "The call traits allow functions to accept closures as parameters, even though…".


In this example, we define a function `ten_times` that takes a higher-order function argument, and we then call it with a closure expression as an argument, followed by a closure expression that moves values from its environment.

Expand Down