Cargo
Cargo is Rust’s package manager and build tool for managing projects and dependencies and for building, testing, and running Rust code.
Learn Rust in a Month of Lunches
Cargo is Rust's package manager and build tool for creating, configuring, compiling, running, and managing Rust projects and their dependencies.
- How it is used
- Uses Cargo to create and manage Rust projects and bring in external crates.
- How deep it goes
- Walks through project creation, dependency setup, build output, and incremental compilation, contrasting Cargo with direct rustc use.
- Examples
- Demonstrates a rand dependency and a program that prints a random number, then shows rebuilding after changing a letter list.
- What you can do after
- Apply it via Cargo to create a project, add a dependency, and build or run a program.
Rust in Action: Systems programming concepts and techniques
Cargo is Rust's package manager and build system for creating, compiling, running, documenting, and managing Rust projects.
- How it is used
- Uses Cargo to manage Rust projects, from a first executable to projects with third-party dependencies.
- How deep it goes
- Walks through project creation, building, dependencies, and verbose compiler output without detailing Cargo’s implementation.
- Examples
- Uses a Hello World project, a regex search project, and a clock application to demonstrate Cargo workflows.
- What you can do after
- Apply it via Cargo to create, build, run, and add dependencies to Rust projects.
Read how Rust in Action: Systems programming concepts and techniques explains Cargo →
Code Like a Pro in Rust
Cargo is Rust's official build system and package manager.
- How it is used
- Uses Cargo as the primary interface for managing, building, testing, and publishing Rust projects.
- How deep it goes
- Walks through project creation, core commands, and dependency version requirements, including iteration and pinning trade-offs.
- Examples
- Demonstrates generated application and library projects, a build-versus-check timing comparison, and a rand dependency.
- What you can do after
- Operate Cargo to create projects, build and test code, and manage dependencies.
Rust Servers, Services, and Apps
Cargo is Rust's build system and package manager for creating, compiling, testing, and managing Rust projects and dependencies.
- How it is used
- Organizes Rust application workspaces, creates packages, configures dependencies, and runs selected server binaries.
- How deep it goes
- Explains workspace layout, package creation, manifests, dependencies, binary declarations, and run commands, but not build-system internals.
- Examples
- Uses scenario1 and ezytutors workspaces, TCP client-server binaries, an HTTP library, and a basic Actix health server.
- What you can do after
- Builds and operates multi-package Rust projects by creating workspaces, configuring manifests, adding dependencies, and running named binaries.
Refactoring to Rust
Cargo is Rust's package manager and build system for creating, compiling, running, testing, and distributing Rust projects.
- How it is used
- Creates, builds, runs, configures, links, and publishes Rust packages and their dependencies.
- How deep it goes
- Explains core commands and Cargo.toml dependency configuration, stopping short of broader workflow details.
- Examples
- Uses art-museum, calculate with libc, and ngx_http_calculator_rs around NGINX 1.19.3.
- What you can do after
- Operate Cargo to create projects, run programs, add dependencies, build crates, and prepare library-based integrations.
Rust Web Development
Cargo is Rust’s package manager and build tool.
- How it is used
- Creates Rust projects and builds and runs their applications.
- How deep it goes
- Demonstrates project creation, compilation, execution, and generated files; defers the distinction between `main.rs` and `lib.rs`.
- Examples
- Uses `cargo new hello` and `cargo run` to build and execute a Hello, world! program.
- What you can do after
- Build and run a basic Rust project with `cargo new` and `cargo run`.
Embedded Software with Rust
Cargo is Rust's package manager and build system, providing dependency management, compilation, testing, and related project workflows.
- How it is used
- Coordinates embedded Rust builds and project workflows, including target selection, binary inspection, flashing, debugging, and testing.
- How deep it goes
- Configures targets, runners, linker flags, dependency locks, and feature-selected panic handlers; broader binary workflows are outlined.
- Examples
- Uses a Cortex-M target with a GDB/OpenOCD runner and feature-selected semihosting or halt panic handlers.
- What you can do after
- Configure embedded targets, runners, and linker settings, then build diagnostic or silent panic variants with Cargo features.
Also covered in
What to know first
- RustRust is a statically typed systems programming language designed for performance, concurrency, and memory safety without requiring garbage collection.
- 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.
Related concepts
- compileruses · A compiler is software that translates source code into another representation, such as machine code, bytecode, or an intermediate form.
- build scriptuses · A build script is an executable program or declarative specification that automates or configures tasks for building software artifacts.
- crates.iouses · crates.io is the public package registry and distribution service for Rust crates.
- package managerkind of · A package manager is software that retrieves, resolves, installs, updates, removes, and manages software packages and their dependencies.
Questions about Cargo
What is Cargo?
Cargo is Rust’s package manager and build tool for managing projects and dependencies and for building, testing, and running Rust code.
Which Manning books explain Cargo?
Learn Rust in a Month of Lunches, Rust in Action: Systems programming concepts and techniques, Code Like a Pro in Rust, Rust Servers, Services, and Apps, Refactoring to Rust, Rust Web Development and Embedded Software with Rust.
What should I know before learning Cargo?
Manning books that teach Cargo usually introduce Rust, application, crate and generics first.
What is Cargo a kind of?
Cargo is a kind of package manager. A package manager is software that retrieves, resolves, installs, updates, removes, and manages software packages and their dependencies.
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.






