Cargo run
cargo run is a Cargo command that builds and executes a Rust package’s binary target.
Learn Rust in a Month of Lunches
cargo run is a Cargo subcommand that builds and runs a Rust binary target while resolving its dependencies.
- How it is used
- Uses Cargo to build and run a Rust program while bringing in its dependencies.
- How deep it goes
- Walks through compilation output and a repeat run that reuses previously compiled dependencies.
- Examples
- Runs a random-letter program using rand, then adds a letter and runs it again.
- What you can do after
- Apply it via Cargo to build and test a program with an external crate.
Read how Learn Rust in a Month of Lunches explains cargo run →
Rust in Action: Systems programming concepts and techniques
cargo run is a Cargo subcommand that builds a Rust project and executes its resulting binary.
- How it is used
- Uses Cargo to build and execute Rust projects from a console.
- How deep it goes
- Explains project setup, build artifacts, release and quiet flags, and verbose compiler output.
- Examples
- Runs a generated Hello world project and a CSV-processing program with debug, release, and quiet output.
- What you can do after
- Apply it via Cargo to build and run a project, select a release build, or inspect compilation commands.
Read how Rust in Action: Systems programming concepts and techniques explains cargo run →
Also covered in
What to know first
- applicationAn application is a software program or system that provides functionality or performs tasks for users or other software.
- 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.
- genericsGenerics are programming-language constructs parameterized by types, allowing definitions to apply to multiple concrete types while preserving type relationships.
- RustRust is a statically typed systems programming language designed for performance, concurrency, and memory safety without requiring garbage collection.
Related concepts
- Cargopart of · Cargo is Rust’s package manager and build tool for managing projects and dependencies and for building, testing, and running Rust code.
- codeuses · Code is a set of instructions and declarations expressed in a programming language that specifies computational behavior.
- standard errorproduces · Standard error is a process’s conventional output stream for diagnostic and error messages, separate from standard output.
- cargo buildalternative to · cargo build is a Cargo command that compiles a Rust package and produces build artifacts without running them.
- randuses · rand is a Rust library crate that provides random-number generation and related randomization utilities.
- debugging modeuses · Debugging mode is a software build or runtime configuration that enables facilities for inspecting program behavior and diagnosing errors.
Questions about cargo run
What is cargo run?
cargo run is a Cargo command that builds and executes a Rust package’s binary target.
Which Manning books explain cargo run?
Learn Rust in a Month of Lunches and Rust in Action: Systems programming concepts and techniques.
What should I know before learning cargo run?
Manning books that teach cargo run usually introduce application, crate, generics and Rust first.
What is the difference between cargo run and cargo build?
cargo run is a Cargo command that builds and executes a Rust package’s binary target. cargo build is a Cargo command that compiles a Rust package and produces build artifacts without running them.
What is cargo run part of?
Cargo run is part of Cargo. Cargo is Rust’s package manager and build tool for managing projects and dependencies and for building, testing, and running Rust code.
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.

