Skip to content

Commit

Permalink
Clarify pub use example. Fixes #2716.
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Mar 29, 2022
1 parent 14a3033 commit 0d2ea76
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ changed to `pub use`.
<span class="caption">Listing 7-17: Making a name available for any code to use
from a new scope with `pub use`</span>

By using `pub use`, external code can now call the `add_to_waitlist` function
using `hosting::add_to_waitlist`. If we hadn’t specified `pub use`, the
`eat_at_restaurant` function could call `hosting::add_to_waitlist` in its
scope, but external code couldn’t take advantage of this new path.
Before this change, external code would have to call the `add_to_waitlist`
function by using the path
`restaurant::front_of_house::hosting::add_to_waitlist()`. Now that this `pub
use` has re-exported the `hosting` module from the root module, external code
can now use the path `restaurant::hosting::add_to_waitlist()` instead.

Re-exporting is useful when the internal structure of your code is different
from how programmers calling your code would think about the domain. For
Expand Down

0 comments on commit 0d2ea76

Please sign in to comment.