Skip to content

Cargo

Cargo

Cargo is the Rust package manager. Cargo downloads your Rust package’s dependencies, compiles your packages, makes distributable packages, and uploads them to crates.io, the Rust community’s package registry. You can contribute to this book on GitHub.

Cargo Commands

Module

Rust’s module system is used to organize code into logical units called modules, which provide isolated namespaces within the code.

The source code for a given crate may be subdivided into one or more separate modules.

Package

A package is a collection of source files and a Cargo.toml manifest file which describes the package. A package has a name and version which is used for specifying dependencies between packages.

A package contains multiple targets, each of which is a crate.

Crate

A Rust crate is either a library or an executable program, referred to as either a library crate or a binary crate, respectively.

Every target defined for a Cargo package is a crate.