-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
Description
-
I have searched open and closed issues and pull requests for duplicates, using these search terms:
- fn type
- 19-05
-
I have checked the latest
main
branch to see if this has already been fixed, in this file:
URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch19-05-advanced-functions-and-closures.html#returning-closures
Description of the problem:
The book says that “you’re not allowed to use the function pointer fn as a return type”. However, the provided example successfully compiles using the fn type.
example in the main branch:
fn returns_closure() -> impl Fn(i32) -> i32 {
|x| x + 1
}
does compile and is allowed to use the fn type.
Suggested fix:
Clarify that a closure that does not capture its environment can be coerced into a function pointer.