Paths for Referring to an Item in the Module Tree
The example in the book says the below rust program should compile. But the compile complains as seen below.
mod front_of_house {
mod hosting {
pub fn add_to_waitlist() {}
fn seat_at_table() {}
}
fn eat_at_restaurant() {
crate::front_of_house::hosting::add_to_waitlist();
front_of_house::hosting::add_to_waitlist();
}
mod serving {
fn take_order() {}
fn serve_order() {}
fn accept_payment() {}
}
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0433]: failed to resolve: use of undeclared crate or module `front_of_house`
--> src/lib.rs:9:5
|
9 | front_of_house::hosting::add_to_waitlist();
| ^^^^^^^^^^^^^^ use of undeclared crate or module `front_of_house`
For more information about this error, try `rustc --explain E0433`.
error: could not compile `playground` (lib) due to previous error
rustup --show
Default host: x86_64-apple-darwin
rustup home: /Users/boredmgr/.rustup
stable-x86_64-apple-darwin (default)
rustc 1.75.0 (82e1608df 2023-12-21)