I am reading the Rust Book and I got a bit confused by Re-exporting Names with pub use:
mod front_of_house {
pub mod hosting {
pub fn add_to_waitlist() {}
}
}
pub use crate::front_of_house::hosting;
pub fn eat_at_restaurant() {
hosting::add_to_waitlist();
hosting::add_to_waitlist();
hosting::add_to_waitlist();
}
Quote:
By using
pub use
, external code can now call theadd_to_waitlist
function usinghosting::add_to_waitlist
.
What is external code in this context? It's not clear from the examples how the code snippet above is different to:
use crate::front_of_house::hosting::add_to_waitlist;