Skip to content
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

Improve awkward phrasing around the kinds of closures #3290

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions src/ch13-01-closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,13 @@ Using `FnOnce` in the trait bound expresses the constraint that
`unwrap_or_else` is only going to call `f` at most one time. In the body of
`unwrap_or_else`, we can see that if the `Option` is `Some`, `f` won’t be
called. If the `Option` is `None`, `f` will be called once. Because all
closures implement `FnOnce`, `unwrap_or_else` accepts the most different kinds
of closures and is as flexible as it can be.
closures implement `FnOnce`, `unwrap_or_else` accepts all closures and is as
flexible as it can be.
chriskrycho marked this conversation as resolved.
Show resolved Hide resolved

> Note: Functions can implement all three of the `Fn` traits too. If what we
> want to do doesn’t require capturing a value from the environment, we can use
> the name of a function rather than a closure where we need something that
> implements one of the `Fn` traits. For example, on an `Option<Vec<T>>` value,
> implements one of the `Fn` traits. For example, on an `Option<Vec<T>>` value
chriskrycho marked this conversation as resolved.
Show resolved Hide resolved
> we could call `unwrap_or_else(Vec::new)` to get a new, empty vector if the
> value is `None`.

Expand Down