This chapter covers
- Grouping your functions into modules
- Splitting your modules into files
- Creating a practical folder structure within your Rust project
- Understanding the difference between doc comments and hidden comments
- Adding example code in your comments and testing it
- Using Clippy to lint your code
- Using Cargo to format and compile your codebase
Rust comes equipped with a large set of tools that makes it easy to organize, structure, test, and comment it. The ecosystem values good documentation style, which is the reason Rust has a built-in commenting system that generates code documentation on the fly, and even tests the code in your comments so your documentation is never out-of-date.
A widely supported linter called Clippy is the de facto standard in the Rust world. It comes with many preset rules and helps point out best practices or missing implementations. In addition, Rust’s package manager Cargo helps autoformat your code based on predefined rules.