April 2026
Intermediate
631 pages
16h 20m
English
As covered in the previous section, modules are the finest level of code organization. We’ll start this section by explaining the need for modules, followed by the basics of creating modules. Next, we’ll elaborate on the difference between relative and absolute paths for accessing items contained within a module. Finally, we look at the issue of privacy and the use declaration for importing items.
Consider the code shown in Listing 6.4, which is inside a library crate representing an online store and provides basic services such as creating products, maintaining customer’s data, and processing an order.
struct Product { id: u64, name: String, price: f64, category: Category,}enum
Read now
Unlock full access