mirror of
https://github.com/rust-lang/book.git
synced 2026-12-01 04:38:03 -06:00
Ch. 07: Clarify sentences about pub use
This is still a *bit* finicky, but it is slightly clearer than before, and at least addresses the underlying issue here. Fixes #3645
This commit is contained in:
@@ -130,12 +130,12 @@ considered idiomatic, so the choice is up to you!
|
||||
|
||||
### Re-exporting Names with `pub use`
|
||||
|
||||
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`. This technique is called _re-exporting_ because we’re bringing an
|
||||
item into scope but also making that item available for others to bring into
|
||||
their scope.
|
||||
When we bring a name into scope with the `use` keyword, the name is private to
|
||||
the scope into which we imported it. To enable code outside that scope to refer
|
||||
to that name as if it had been defined in that scope, we can combine `pub` and
|
||||
`use`. This technique is called _re-exporting_ because we’re bringing an item
|
||||
into scope but also making that item available for others to bring into their
|
||||
scope.
|
||||
|
||||
Listing 7-17 shows the code in Listing 7-11 with `use` in the root module
|
||||
changed to `pub use`.
|
||||
|
||||
Reference in New Issue
Block a user