23.15 Summary

Cargo is central to modern Rust development. Its features include:

  • Project Creation: cargo new, cargo init
  • Building & Running: cargo build, cargo run (debug vs. release)
  • Dependency Management: Declare in Cargo.toml and lock with Cargo.lock
  • Testing & Documentation: cargo test for comprehensive test discovery, cargo doc for API docs
  • Publishing: Upload crates to Crates.io with version tracking and optional yanking
  • Workspaces: Manage multiple interdependent crates in a single repository
  • Extensibility & Tooling: Includes cargo fmt, cargo clippy, cargo fix, cargo miri, plus the ability to add custom subcommands

By mastering Cargo, you gain an integrated workflow for building, testing, documenting, and publishing Rust projects. This ensures reliable builds, consistent dependencies, and smooth collaboration in the Rust community.