This recipe discusses how to create a file structure for complex and bigger code bases so that it would be easier for the developer to manage application feature development. We will learn about the rules enforced by the Rust compiler to create a file hierarchy successfully so that the developer can utilize and get the same flexibility while using modules' units.
We will require the Rust compiler and any text editor to code. Also, create a file named sample_module.rs
in the project workspace.
- Create a file named
sample_split.rs
and a folder namedsample_module
in the project workspace:
touch sample_split.rs && mkdir sample_module
- Create the
mod.rs
,nested_mod.rs
, andsample_private.rs
files inside thesample_module
folder:
cd sample_module && touch mod.rs nested_mod.rs sample_private.rs
We should get a folder structure, as shown in the following screenshot:
- Write the code header with the details of the code...