liveBook · Manning

Dependency

As explained in Rust in Action: Systems programming concepts and techniques

A dependency is an external software package required by a project.

A dependency is an external software package that a project needs. In Rust, Cargo records dependencies in Cargo.toml, downloads and compiles them, and manages build artifacts such as Cargo.lock and target/. section 1.3.1 section 2.11

A dependency connects several project activities:

Adding a regular-expression dependency

Create a project with cargo new grep-lite --vcs none, enter its directory, and run cargo add regex@1. Cargo changes Cargo.toml to include regex, then cargo build downloads regex and supporting crates, compiles them, and builds grep-lite. The project can then grow from exact matching to regular-expression searches. section 2.11

  Updating crates.io index
Downloaded regex v1.3.6
 Compiling lazy_static v1.4.0
 Compiling regex-syntax v0.6.17
 Compiling thread_local v1.0.1
 Compiling aho-corasick v0.7.10
 Compiling regex v1.3.6
 Compiling grep-lite v0.1.0 (/tmp/grep-lite)
  Finished dev [unoptimized + debuginfo] target(s) in 4.47s

The build output makes dependency resolution visible: Cargo updates the crates.io index, downloads regex, compiles its supporting crates, and finishes the project build. section 2.11

How Rust in Action: Systems programming concepts and techniques covers it

How deep it goes
Explains declaration, downloading, compilation, and build artifacts, but stops short of dependency-resolution internals.
Examples
Demonstrates dependencies through the regex crate in the grep-lite project and Cargo's compilation output.
What it assumes
Assumes an installed Rust toolchain and command-line access, while teaching dependency addition through Cargo.
What you can do after
Apply it via Cargo by adding a crate, building the project, and using the third-party functionality.
How it connects
Connects dependencies with Cargo, Cargo.toml, Cargo.lock, crates, package management, and build systems.

Also explained in

Compare how 27 books explain dependency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.