liveBook · Manning

Crate

A crate is Rust’s unit of compilation and distribution, containing source code and metadata for a library or executable.

How 2 Manning books explain it

Code Like a Pro in Rust

A crate is a Rust package containing source code and metadata that can be compiled and distributed as a library or application.

How it is used
Organizes Rust applications and libraries as Cargo-managed packages that can depend on, test, and distribute one another.
How deep it goes
Works through dependency declarations, workspace membership, patching, publishing, and test boundaries without detailing crate compilation internals.
Examples
Uses a rand manifest entry, a library in a workspace, a patched num_cpus dependency, and quicksort integration tests.
What you can do after
Operate/configure it with Cargo to declare dependencies, group workspace members, test public APIs, patch dependencies, and publish eligible crates.

Read how Code Like a Pro in Rust explains crate →

Learn Rust in a Month of Lunches

An external crate is a Rust compilation unit published outside the current project for other programs to depend on.

How it is used
Uses external crates to add functionality from outside a Rust project, including random-number generation absent from the standard library.
How deep it goes
Defines crates and external crates, then walks through adding a dependency and using it; does not detail Cargo’s dependency internals.
Examples
Shows a Cargo.toml entry for rand and dice rolls used to generate character statistics.
What you can do after
Apply it via Cargo by adding a crate dependency and using the crate’s code in a Rust program.

Read how Learn Rust in a Month of Lunches explains crate →

Related concepts

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.