This chapter covers
- Introducing Cargo and how to manage Rust projects with Cargo
- Handling dependencies in Rust projects
- Linking to other (non-Rust) libraries
- Publishing Rust applications and libraries
- Documenting Rust code
- Following the Rust community’s best practices for managing and publishing projects
- Structuring Rust projects with modules and workspaces
- Considerations for using Rust in embedded environments
Before we can jump into the Rust language itself, we need to familiarize ourselves with the basic tools required to work with Rust. This may seem tedious, but I can assure you that mastering tooling is critical to success. The tools were created by the language creators for the language users to make your life easier, so understanding their purpose will forever pay dividends.
Rust’s package management tool is called Cargo, and it’s the interface to Rust’s compiler rustc, the https://crates.io registry, and many other Rust tools (which we cover in more detail in chapter 3). Strictly speaking, it’s possible to use Rust and rustc without using Cargo, but it’s not something I’d recommend for most people.
When working with Rust, you’ll likely spend a lot of time using Cargo and tools that work with Cargo. It’s important to familiarize yourself with its use and best practices. In chapter 3, I’ll provide recommendations and details on how to further increase the usefulness of Cargo with community crates.