Closed
Description
- I have checked the latest
main
branch to see if this has already been fixed - I have searched existing issues and pull requests for duplicates
URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch03-03-how-functions-work.html
Description of the problem:
The current wording states:
Rust doesn’t care where you define your functions, only that they’re defined somewhere.
Which motivated me to try e.g. which does work:
fn main() {
a_function();
fn a_function() {
println!("Hello, World!");
}
}
But something like:
fn main() {
a_function();
{
fn a_function() {
println!("Hello, World!");
}
}
}
Doesn't compile because the function is not found in the scope.
I think this is a contradiction with the documentation.
Suggested fix:
Change the wording to maybe:
Rust doesn’t care where you define your functions, only that they’re defined somewhere in scope.