2.1 The Compilation Process

Like C, Rust is a compiled language. Rust's compiler (rustc) translates .rs source files into a binary executable. However, Rust also provides Cargo, an integrated build system and package manager that streamlines the compilation and project organization process.

2.1.1 Cargo: Rust's Build System and Package Manager

Cargo combines the roles of tools like make or cmake and dependency managers. It handles compilation, manages external libraries (called "crates"), runs tests, and more.

Creating and building a new Rust project:

cargo new my_project
cd my_project
cargo build

Cargo generates a standard directory layout (with src/ for code, Cargo.toml for metadata), which helps in managing larger codebases consistently.