liveBook · Manning

Cargo

As explained in Refactoring to Rust

Cargo is Rust's package manager and build system for creating, compiling, running, testing, and distributing Rust projects.

Cargo is Rust’s package manager and build system. It creates project structure, compiles and runs programs, manages dependencies, links crates, and supports package publication. section 2.1 section 3.2.1

Common Cargo tasks include:

Adding libc to a crate

Add libc under [dependencies] in Cargo.toml, then run cargo build. Cargo updates the crates.io index, downloads and compiles the requested version, and links it without a separate compiler-flag step. section 3.2.1

$ cargo new art-museum

A minimal command creates an art-museum project with the files needed to begin writing Rust. section 2.1

Listing 3.3 Default Cargo configuration file
[package]
name = "calculate"
version = "0.1.0"
authors = ["You <you@you.com>"]
edition = "2018"

# See more keys and their definitions at
# https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

The generated Cargo.toml records package identity, version, authors, edition, and an initially empty dependency table. section 3.2.1

How Refactoring to Rust covers it

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.
How it connects
Connects Rust packages with crates, Cargo.toml, crates.io, dependencies, linking, and C foreign-function interfaces.

Also explained in

Compare how 5 books explain Cargo →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Refactoring to Rust. The section links point to the parts of the book it draws on.