TIL: Rust documentation redirects
Published Aug 1, 2022
docs.rs/stdtakes you to Rust
stddocs, as if it was a crate name!
I’m learning Rust (for the third time now) (and I mean it this time!), and I’m getting deep enough into it that I’m learning shortcuts.
Based on the URL structure for crate documentation (for example,
https://docs.rs/axum/latest/axum/), you might wonder whether
https://docs.rs/axum takes you anywhere.
Spoiler: it does! And it takes you to the longer
latest URL, as you’d probably expect.
This is super cool, because that’s a convenient shortcut to the docs for any crate.
docs.rs/axum into any good browser’s URL bar takes you straight there.
But some documentation isn’t hosted on
In particular, the Rust standard library is on
rust-lang.org, and I can never remember the URL structure for that.
https://doc.rust-lang.org/stable/std, by the way).
In the case that brought me to write this, I wanted docs for
std::option::Option because I can’t yet cold-recall which of the
unwrap variants I want.
So I wondered what would happen if I went to
And it worked! Those Rustaceans think of everything! 🦀
Like all good dev tools,
docs.rs is open-source.
There are other special-cased paths, but I’ll leave you to read
src/web/routes.rs to figure out what they are 😉