menu_book Course Curriculum (Rust) expand_more
Crate Structure and Main
Learn Crate Structure and Main in Rust through a focused explanation, a dedicated topic-specific example, an engineering boundary, and a mastery check.
Crate Structure and Main is a focused Rust lesson inside Rust Foundations. It teaches how Crate Structure and Main shapes data, behavior, dispatch, or representation.
Read the example from the construct outward: identify the exact syntax or API named by the lesson, trace the values that enter it, and predict the result before running the code. The example is intentionally different from neighboring lessons so the behavior of Crate Structure and Main remains visible instead of being hidden inside a generic demo.
Topic-specific example
mod pricing {
pub fn total(quantity: i32, cents: i32) -> i32 {
quantity * cents
}
}
fn main() {
println!("{}", pricing::total(3, 250));
}
For Crate Structure and Main, reproduce the example from a clean build. Hidden local state, stale artifacts, and accidental transitive dependencies are common sources of misleading success.