LinuxCommandLibrary

rustup-doc

Open Rust documentation in a web browser

TLDR

Open the main page

$ rustup doc
copy

Open the documentation for a specific topic (a module in the standard library, a type, a keyword, etc.)
$ rustup doc [std::fs|usize|fn|...]
copy

Open the Rust Programming Language book
$ rustup doc --book
copy

Open the Cargo book
$ rustup doc --cargo
copy

Open the Rust Reference
$ rustup doc --reference
copy

SYNOPSIS

rustup doc [OPTIONS] [path]

PARAMETERS

-h, --help
    Show help message and exit.

--host
    Specifies the target host triple (e.g., x86_64-unknown-linux-gnu) for which to open documentation.

--toolchain
    Selects the specific toolchain (e.g., stable, nightly, 1.60.0) whose documentation should be opened.

-V, --version
    Print version information and exit.

[path]
    An optional argument to open a specific part of the documentation (e.g., std, cargo, std::collections::HashMap). If omitted, the main documentation index is opened.

DESCRIPTION

The rustup-doc command, part of the rustup toolchain installer, provides a convenient way to access the Rust programming language's official documentation locally on your system. When executed, it automatically opens the installed documentation in your default web browser, allowing for quick, offline access to the standard library, Cargo, and other essential Rust components' APIs. This eliminates the need for an internet connection to consult documentation, making it an indispensable tool for Rust developers. It is crucial for the rust-docs component to be installed for the command to function correctly.

CAVEATS

The rust-docs component must be installed for the target toolchain using rustup component add rust-docs.
A web browser configured for your system is required to open the documentation.
Some distributions might require specific browser configuration or environment variables (like BROWSER) for this command to function correctly.

INSTALLATION REQUIREMENT

For rustup-doc to function, the documentation component must be added to your installed toolchain. This can be done via:
rustup component add rust-docs

USAGE EXAMPLES

Open the main documentation index:
rustup doc

Open documentation for a specific module:
rustup doc std::collections

Open Cargo documentation:
rustup doc cargo

Open documentation for a specific toolchain (e.g., nightly):
rustup doc --toolchain nightly

HISTORY

The rustup tool, which includes rustup-doc, was created to simplify the management of Rust toolchains and components. It addressed challenges in installing and updating Rust versions, ensuring developers always have access to the correct compiler, standard library, and, crucially, its documentation. rustup-doc provides an invaluable service for developers, enabling quick, offline access to the extensive Rust API documentation, which is vital for productivity and learning.

SEE ALSO

Copied to clipboard