6.9 Summary
In this chapter, we explored various techniques for organizing code effectively in Rust. We started by discussing the importance of code organization and introduced modules as a way to structure your code, using an online store example to illustrate their value. You learned how to create modules, how to navigate to items using relative and absolute paths, and how to handle privacy within modules. This chapter also covered the use declaration for bringing items into scope, ultimately improving code readability.
We then examined ways to visualize and organize modules, using Cargo to view module hierarchies and adopting typical file system structures to maintain clarity. We discussed re-exporting and privacy, with a focus on managing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access