Skip to content

Explain pub use in Chapter 7 with a more robust example #2716

@Defman21

Description

@Defman21

In the version 1.0.0 of the book, the example for the pub use keyword is more self-explanatory than in the current one because it demonstrates how exactly pub use works (instead of calling languages::japanese::greetings::hello we can simply do languages::japanese::hello if we include pub use self::greetings in the languages::japanese module). The current version only slightly mentions its behavior:

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.

An example showing how it would be called in an external module similar to the version 1.0.0 would be much helpful to understand the concept of re-export.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions