Crate
A crate is Rust’s unit of compilation and distribution, containing source code and metadata for a library or executable.
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.
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.
Related concepts
- Criterion.rsincludes · Criterion.rs is a Rust benchmarking library for statistically driven measurement and evaluation of code performance.
- Crosstermincludes · Crossterm is a Rust cross-platform terminal I/O library for handling events such as keyboard input, mouse input, and terminal resizing.
- Cargoused by · Cargo is Rust’s package manager and build system for managing projects, dependencies, compilation, testing, and related workflows.
- randincludes · rand is a Rust library crate providing random-number generation and related randomization utilities.
- libraryequivalent to · A software library is a reusable collection of code or components that other programs can incorporate or invoke to provide functionality.
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.

