DEV Community

Discussion on: Understanding Rust Imports

Collapse
 
msfjarvis profile image
Harsh Shandilya

It's indeed complicated but a good way to learn is to remember that as a rule of thumb, all your modules must be exported by main.rs or lib.rs (depending on the type of crate). In your final example, you don't need to do pub use, pub(crate) use works better to export the module to the entire crate without making it public API (if you're building a library project).

Collapse
 
winstonpuckett profile image
Winston Puckett

Ooh. That's good to know, thank you :)