Cargo Commands
Rust build system and package manager.All Cargo pages
- cargo add serde --features derive: add a dependency with featurescargo add NAME --features F adds a crate to Cargo.toml with chosen features (Cargo 1.62+). Pin versions, dev and build deps, default features, and cargo remove.
- cargo new: create a new Rust project (binary or library)cargo new hello creates a Rust binary package with Cargo.toml, src/main.rs and Git; --lib makes a library. Options, naming rules, cargo init and pitfalls.
- cargo run -- args: pass command-line arguments to a Rust programcargo run -- args passes command-line arguments to your Rust program; options without the double dash go to Cargo. Release builds, --bin, examples and pitfalls.
- cargo test name: run a single test (or one module) in Rustcargo test name runs only tests whose path contains the name; -- --exact matches one test. Select modules, targets and ignored tests, show output and more.