Today we are going to talk about the Rust project structure and how to organize your code. Although cargo workspace also enters in this equation we’ll not talk about it, for the sake of simplicity.
When we write small programs it’s simple to keep tracking of the entire functionalities inside our head. To make simple calculus or exercise some algorithms you can do everything with just one single source code file, the problem is when you need to add even more functionalities to the scope.
In normal software projects, you need to write a lot more. The amount of source code will increase drastically and will be impossible to keep track of everything inside your head. Because of that you need to organize everything in a meaningful way.
This organization must encapsulate the implementations to show the compiler and programmers where everything is and how it is organized.
Rust’s way to solve this problem is to create 4 hierarchical structures in a Modular System(https://en.wikipedia.org/wiki/Modular_programming):
Let’s see each one of them.
#rust