-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
rust-lang/rust
#95423Labels
Milestone
Description
In the section "Separating Modules into Different Files", authors show how to separate modules in many files. At the end of the example, the user folder structure looks like this:
├── Cargo.lock
├── Cargo.toml
├── src
│ ├── front_of_house
│ │ └── hosting.rs
│ ├── front_of_house.rs
│ └── lib.rs
Copying the code snippets for each file using the copy icon gives:
lib.rs
mod front_of_house;
pub use crate::front_of_house::hosting;
pub fn eat_at_restaurant() {
hosting::add_to_waitlist();
hosting::add_to_waitlist();
hosting::add_to_waitlist();
}
front_of_house.rs
pub mod hosting;
front_of_house/hosting.rs
#![allow(unused)]
fn main() {
pub fn add_to_waitlist() {}
}
Using this snippets, cargo check
fails:
error[E0425]: cannot find function `add_to_waitlist` in module `hosting`
--> src/lib.rs:6:14
|
6 | hosting::add_to_waitlist();
| ^^^^^^^^^^^^^^^ not found in `hosting`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0425`.
error: could not compile `restaurant`
To learn more, run the command again with --verbose.
It works using:
front_of_house/hosting.rs
pub fn add_to_waitlist() {}