book icon indicating copy to clipboard operation
book copied to clipboard

Chapter 7 - Page 135: Re-exporting Names with pub use

Open alamba78 opened this issue 2 years ago • 1 comments

  • I have searched open and closed issues and pull requests for duplicates, using these search terms:
    • is:issue is:open is:closed re-exporting
    • is:issue is:open is:closed re-exporting Names
    • is:issue is:open is:closed re-exporting pub use
  • 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/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html Description of the problem: The text is a little confusing and could be made more clear.

The text states, "When we bring a name into scope with the use keyword, the name available in the new scope is private. To enable the code that calls our code to refer to that name as if it had been defined in that code's scope, we can combine pub and use."

Suggested fix: It might be more clear written as "When we bring a name into scope with the use keyword, the name available in that scope is available to be used, while the name is private in any other scope. To enable our external code, found in another scope, to refer to that name as if it had been defined in that code's scope, we can combine pub and use."

The part that is confusing is "To enable the code that calls our code..", and later refer to 'code that calls our code' as external code. It might be more clear to use 'external code' consistently throughout the explanation.

alamba78 avatar May 14 '23 12:05 alamba78

Thanks for opening the issue. I agree that the wording could be improved here, but as you discovered, it will be tricky to get it just right! Flagging it up as a possible fix for the next edition of the book, though!

chriskrycho avatar Apr 01 '24 20:04 chriskrycho