cargo doc generates HTML documentation for a Rust crate, making its public API easier to inspect and use. The output appears in target/doc, with the crate index as its landing page. section 6.11.2
Use cargo doc to:
- Inspect public structs and methods, even before adding explicit documentation. section 6.11.2
- Evaluate API design through names, crate-level descriptions, method explanations, and usage examples. section 6.11.2
- Regenerate documentation continuously with cargo watch -x doc while editing. section 6.11.2
Documenting a linked-list crate
Run cargo doc, then open target/doc/linkedlist/index.html. Add //! comments to src/lib.rs for crate-level guidance and /// comments before LinkedList and its methods. Regenerate the documentation to see the landing page and API descriptions become more useful. section 6.11.2

