Chapter 2: Structuring Code in Rust
Now that we have gotten to grips with the basics of Rust, we can move on to structuring code over several files so we can actually solve problems with Rust. In order to do this, we will have to understand how to manage dependencies as well as how to compile a basic and structured application. We also have to consider the isolation of code so we can reuse it and keep the development of the application agile, enabling us to make changes quickly without much pain. After covering this, we will also get the application to interact with the user directly by accepting user commands. We will also utilize Rust crates. A crate is a binary or library that we import and use.
In this chapter, we will cover the following topics:
- Managing our code with crates and Cargo instead of
pip
- Structuring code over multiple files and modules
- Building module interfaces
- Interacting with the environment