A parent cannot see into a child’s private items, but a child can see into its parent’s items using super.
modback_of_house{
fnfix_incorrect_order(){
super::deliver_order();// ⬅️ Accessing parent (like `../../` in JS)
}
}
📥 use (The JS import)
Bring items into scope to avoid long paths.
use std::collections::HashMap;
use std::io::Result as IoResult;// Aliasing (like `import { x as y }`)
fnmain(){
letmut map =HashMap::new();
}
💡 Takeaway for Frontend
Rust’s mod is like your folder structure, and pub is like export. The biggest change: in JS, everything in a file is “visible” to the file. In Rust, you have to explicitly pub modules AND the items inside them to make them accessible from the outside. Use use to pull that code in just like an import.