Cargo add
cargo add is a Cargo subcommand that adds a dependency declaration and its configuration to a Rust package’s manifest.
Rust in Action: Systems programming concepts and techniques
cargo add is a Cargo subcommand that adds a dependency declaration to a Rust project's manifest.
- How it is used
- Adds third-party crates to Rust projects during practical development workflows.
- How deep it goes
- Explains the command, manifest edit, and subsequent compilation, but stops short of its implementation internals.
- Examples
- Uses grep-lite with regex and a Mandelbrot renderer with num as hands-on dependency examples.
- What you can do after
- Operate/configure Cargo by adding dependencies and then building or running projects that use them.
Read how Rust in Action: Systems programming concepts and techniques explains cargo add →
Learn Rust in a Month of Lunches
cargo add is a Cargo command that adds an external crate dependency to a package manifest.
- How it is used
- Adds external crates to a Rust package through Cargo.toml.
- How deep it goes
- Defines the command, its manifest effect, and subsequent download behavior without detailing dependency resolution internals.
- Examples
- Uses cargo add rand and shows rand = "0.8.5" under [dependencies].
- What you can do after
- Operate/configure a Cargo project by adding an external crate from the command line.
Read how Learn Rust in a Month of Lunches explains cargo add →
Also covered in
What to know first
- crateA crate is a unit of Rust code compiled as a library or executable, comprising source code and its module hierarchy and distributable through package metadata.
- macroA macro is a named, reusable construct that expands into generated code or a sequence of commands when invoked, often during preprocessing, compilation, or application execution.
Related concepts
- dependencyconfigures · A dependency is a component, resource, or prerequisite that another software component or activity relies on to function, build, or proceed.
- cargo.tomlconfigures · Cargo.toml is a TOML-formatted manifest file that declares a Rust package’s metadata, dependencies, targets, and build configuration.
- quoteconfigures · quote is a Rust crate and macro for constructing Rust token streams from quasi-quoted syntax.
- randuses · rand is a Rust library crate that provides random-number generation and related randomization utilities.
- reqwestuses · reqwest is a Rust HTTP client library for constructing requests and processing responses, with synchronous and asynchronous APIs.
- synconfigures · syn is a Rust library for parsing source code into syntax trees and manipulating their token representations.
Questions about cargo add
What is cargo add?
cargo add is a Cargo subcommand that adds a dependency declaration and its configuration to a Rust package’s manifest.
Which Manning books explain cargo add?
Rust in Action: Systems programming concepts and techniques and Learn Rust in a Month of Lunches.
What should I know before learning cargo add?
Manning books that teach cargo add usually introduce crate and macro first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

