Reading Rust Documentation Offline

Why

Every time I want to read the documentation for a rust library, including the standard library, I just looked it up online. Something along the lines of “{library} {thing of interest}”

I sorta thought it would be nice if I didn’t need to use the internet to read Rust documentation. I mean, I can just read the man pages for many C functions using man 3 {function}. Why can’t I do it with Rust?

Well, you can. And I decided to figure that out after a period of time I couldn’t access the internet, but wanted to program.

How

Most offline documentation can be accessed using these commands:

Yup. Just those two.

cargo doc generates documentation for the current project and all dependencies. --open just automatically opens it in a browser when done. This command is rather useful, but does not include the standard library documentation.

rustup doc provides access to the standard library documentation. More interestingly, it also provides offline access to:

And a few other resources, through an offline version of this page. Point is: There’s a lot of resources and documentation for Rust that are available to read directly on your computer without the need for an internet connection.

Note: If on Arch, the rust package does not provide documentation files. You should install rustup. The packages are mutually exclusive.