Structuring code over multiple files and modules
In order to build our module, we are going to carry out the following steps:
- Map out our file and folder structure.
- Create our
Stock
structs. - Link our
Stock
struct to the main file. - Use our
stocks
module in the main file. - Add code from another module.
Now that we are at the stage of building out our application over multiple files, we have to define our first module in our application, which is the stocks module:
- We can make our module have the structure defined as follows:
├── main.rs └── stocks ├── mod.rs └── structs ├── mod.rs └── stock.rs
We have taken this structure to enable flexibility; if we need to add more structs...