Chapter 4: The Rust Compiler and Cargo

This chapter introduces the Rust compiler, rustc, and the essential build system and package manager, Cargo. In C or C++, managing the build process (e.g., with Make or CMake) and handling external libraries are typically separate tasks using different tools. Rust, however, integrates both functions tightly within Cargo. Much of Rust’s standard library is deliberately minimal, relying on external libraries—called crates in Rust—for common functionality like random number generation or regular expressions. We will explore how Cargo simplifies adding dependencies, compiling code, managing projects, and integrating helpful development tools. This overview provides the necessary foundation; Chapter 23 offers a more comprehensive look at Cargo’s capabilities.