You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is in the segment: Before this change, external code would have to call the add_to_waitlist function by using the path restaurant::front_of_house::hosting::add_to_waitlist(). External code cannot call the add_to_waitlist() function because the front_of_house module is not marked pub. Code to demonstrate:
lib.rs
mod front_of_house {pubmod hosting {pubfnadd_to_waitlist(){}}}usecrate::front_of_house::hosting;pubfneat_at_restaurant(){
hosting::add_to_waitlist();}
main.rs
fnmain(){
backyard::front_of_house::hosting::add_to_waitlist();// does not compile}
Error:
minds@Zero-Requiem MINGW64 /d/Workspace/Rust/RustBook/backyard (main)
$ cargo c
Checking backyard v0.1.0 (D:\Workspace\Rust\RustBook\backyard)
error[E0603]: module `front_of_house` is private
--> src\main.rs:2:15
|
2 | backyard::front_of_house::hosting::add_to_waitlist();
| ^^^^^^^^^^^^^^ private module
|
note: the module `front_of_house` is defined here
--> d:\Workspace\Rust\RustBook\backyard\src\lib.rs:1:1
|
1 | mod front_of_house {
| ^^^^^^^^^^^^^^^^^^
Suggested fix:
pub needs to be added before mod front_of_house.
The text was updated successfully, but these errors were encountered:
main
branch to see if this has already been fixed, in this file:book/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md
Line 158 in a60f431
URL to the section(s) of the book with this problem: https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#bringing-paths-into-scope-with-the-use-keyword
Description of the problem:
The problem is in the segment:
Before this change, external code would have to call the add_to_waitlist function by using the path restaurant::front_of_house::hosting::add_to_waitlist().
External code cannot call theadd_to_waitlist()
function because thefront_of_house
module is not markedpub
. Code to demonstrate:lib.rs
main.rs
Error:
Suggested fix:
pub
needs to be added beforemod front_of_house
.The text was updated successfully, but these errors were encountered: