Rust Documentation

website·Indexed Apr 14, 2026

https://doc.rust-lang.org/cargo/

Official Rust documentation covering The Rust Programming Language book, Cargo package manager, rustc compiler, and learning resources. Includes guides for downloading dependencies, compiling packages, creating distributable packages, and uploading to crates.io. Available offline via rustup doc.

Tokens
392
Snippets
0
Records
6
Agent score
50%

What's inside Rust

  1. Cargo: Rust Package Manager Overview

    Cargo is Rust's official package manager. It handles downloading Rust package dependencies, compiling packages, creating distributable packages, and uploading them to crates.io—the Rust community's package registry. The Cargo Book documents all aspects of using Cargo.
  2. Cargo Book Documentation Structure

    The Cargo Book is organized into: Getting Started (installation and first crate setup), Guide (using Cargo for development), Reference (detailed configuration topics), Commands (CLI reference), FAQ, and Appendices covering a glossary and Git authentication. Additional resources include the Changelog and links to broader Rust documentation.
  3. Format Rust code automatically with cargo fmt

    Use cargo fmt to automatically format your Rust code according to the Rust Style Guide. This invokes rustfmt internally and produces consistent formatting matching the official style guide.
  4. Get extended error explanations from rustc

    Many Rust compiler errors include error codes. Use rustc --explain <ERROR_CODE> to display extended diagnostics for a specific error. For example, rustc --explain E0308 explains type mismatch errors. You can also browse all error codes in the documentation.
  5. Access Rust documentation offline with rustup doc

    Most official Rust documentation is available offline. Use rustup doc to open the documentation in your browser without an internet connection. This includes The Rust Programming Language book, The Cargo Book, The rustc Book, and the Standard Library API reference.
  6. Generate and view local crate documentation with cargo doc

    Run cargo doc --open to generate documentation for your project and all its dependencies, then open it in your browser. Add the --document-private-items flag to include items not marked pub in the generated documentation.