Cargo

/ˈkɑːr.ɡoʊ/ · Noun · Development

Definitions

  1. The official build tool and package manager for Rust, distributed with the Rust toolchain. A project is described by a Cargo.toml manifest listing its name, version, Rust edition, dependencies, and optional features, while Cargo.lock records the exact dependency versions resolved, so builds are reproducible. Everyday work runs through a small set of commands: cargo new to create a project, cargo build and cargo run to compile and execute, cargo test to run unit, integration, and documentation tests, cargo doc to generate documentation, and cargo publish to upload a crate to the crates.io registry. Dependencies are resolved using semantic versioning, and features let a crate make optional code and dependencies available only when asked. Workspaces manage several related crates with a shared lock file and build directory, and build.rs scripts handle tasks such as compiling C code. Cargo can be extended with custom subcommands, which is how tools such as cargo clippy and cargo fmt are invoked.

    In plain English: Rust's all-in-one tool for building your code, downloading libraries, running tests, and publishing packages.

    Example: "cargo build --release produces an optimized binary; cargo test runs every #[test] function in the project."

Related Terms

Deep Dives Covering This Term