mod
, pub
, use
).Cargo.toml
file.main
function as an entry point.Cargo.toml
and a default binary crate.src/main.rs
.src/lib.rs
.main
function as an entry point.main
entry point.mod front_of_house {
pub mod hosting {
pub fn add_to_waitlist() {}
}
}
pub fn eat_at_restaurant() {
// Absolute path
crate::front_of_house::hosting::add_to_waitlist();
// Relative path
front_of_house::hosting::add_to_waitlist();
}
pub
to make modules, functions, and fields accessible:::
.use
for Convenienceuse
to shorten paths.pub use
src/lib.rs
:src/front_of_house.rs
:src/front_of_house/hosting.rs
.mod
, pub
, use
) is powerful for organizing code.Next steps: Practice by creating a workspace with two crates and exploring the module system further!