June 2021
Beginner
344 pages
8h 9m
English
You can write huge programs in one file, but dividing your code into smaller sections—known as modules in Rust—offers significant advantages:
It’s a lot easier to find your Map functionality in a file named map.rs than it is to remember that it’s somewhere around line 500 of an ever-growing main.rs.
Cargo can compile modules concurrently, leading to much better compilation times.
Bugs are easier to find in self-contained code that limits linkages to other sections of code.
Modules may either be a single rs file or a directory. In this chapter, you’ll use single file modules. You’ll learn to create directory-based modules in Multi-File Modules.
Rust programs are divided into crates and modules ...
Read now
Unlock full access