The module example in the book doesn't compile

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() {
    mod serving {
        fn take_order() {}
        fn serve_order() {}
        fn accept_payment() {}



   Compiling playground v0.0.1 (/playground)
error[E0433]: failed to resolve: use of undeclared crate or module `front_of_house`
 --> src/
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)

In addition, as per the example in book , the hosting module need to be made public too in addition to making the function add_to_waitlist() pub. But as can be seen from the playground example, we need not need to make hosting public . So does this mean we can access members of a non public module if we only make the members public?

I'm on mobile so can't test, but your closing brace for front_of_house is in the wrong place. It should be before eat_at_restaurant.

Thank you @duelafn for the quick help. My bad for overlooking the placement of braces.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.