Defining a module
Crates are the compiled entities that get distributed on machines to execute. All the code of a crate is contained in an implicit root module. This code can then be split up by the developer into code units called modules, which in fact form a hierarchy of sub-modules under the root module. That way the organization of our code can be greatly improved. An evident candidate for a module is the tests code, which we discussed in Chapter 3, Using Functions and Control Structures in the The tests module section.
Modules can also be defined inside other modules, as so-called nested modules. Modules do not get compiled individually; only crates get compiled. All module code is inserted into the crate source file before compilation ...
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