| name | rustdoc |
| description | Rust documentation conventions (RFC 1574). Apply when writing doc comments on public Rust items. Covers summary sentences, section headings, type references, and examples. |
Rust Documentation Conventions (RFC 1574)
Apply these rules when writing doc comments (///) on public Rust items.
Summary Sentence
Every doc comment starts with a single-line summary sentence.
Comment Style
Use line comments, not block comments.
Use //! only for crate-level and module-level docs at the top of the file.
Section Headings
Use these exact headings (always plural):
Type References
Use full generic forms and link with reference-style markdown.
Examples
Every public item should have examples showing usage.
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
Errors Section
Document all error conditions for functions returning Result.
Panics Section
Document all conditions that cause panics.
Safety Section
Required for all unsafe functions.