Cargo Rust Package Manager
doc.rust-lang.org
2
Leaving SiteNav
External Link Disclaimer
You are about to visit doc.rust-lang.org. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
Cargo is the official package manager and build system for the Rust programming language, downloaded alongside the Rust toolchain through rustup. It handles dependency resolution, compilation, testing, documentation generation, and package publishing to crates.io, the community package registry hosting over 150,000 crates. The core workflow begins with creating a new project using the init or new command, which generates a standard directory layout including a manifest file named Cargo.toml containing metadata, dependencies, and build configuration. Dependencies are specified using SemVer version ranges, and the tool automatically fetches compatible versions from the registry, resolves transitive dependencies through a constraint solver, and caches compiled artifacts in the target directory for incremental rebuilds. The build command compiles the project and all dependencies, while the run command compiles and executes in one step. Testing is integrated through the test command, which runs unit tests, integration tests, and documentation tests written directly in doc comments. The check command performs fast type checking without generating code, enabling rapid feedback during development. Cargo also supports feature flags for conditional compilation, workspace management for multi-crate repositories, custom build scripts compiled from build.rs files, and editable path dependencies for local development. The publish command uploads packages to crates.io after validation, while the doc command generates API documentation using rustdoc. Profiles for dev and release builds control optimization levels, debug symbols, and codegen units. Cargo supports vendor for offline builds, edition fields for language feature sets, and patch sections for overriding dependency versions during testing.
Statistics
2
Views
0
Clicks
0
Like
0
Dislike