---
name: document-rust-code
description: Document Rust functions, structs, and their arguments following the concise guidelines in .cursor/commands/document-rust-code.md. Use when the user asks to document Rust code, requests doc updates, or references the document-rust-code instructions.
---

# Document Rust Code

## Quick start

1. **Top-of-file rustdoc** – Begin each file with a single multi-line rustdoc comment that summarizes the module’s purpose. Keep it concise but informative so future readers know the intent before diving into details.
2. **Struct documentation** – Above every `struct`, insert a doc comment that explains what the struct represents and any important invariants or relationships. Mention key fields if they clarify usage.
3. **Function documentation** – For each function:
   - Describe what it does.
   - List every parameter with its type and a short explanation of how it is used.
   - Explain what the function returns, including the type and any important behaviors (e.g., error conditions, side effects).
   - If you mention arguments or return values inline, keep the tone informative and avoid emojis or colloquial language.
4. **Additional notes** – If a function has contextual requirements (e.g., certain headers, side effects, or expected state), note them clearly in the doc comment body. Keep sentences succinct and technical.

## Additional guidance

- Prefer consistent terminology (e.g., “argument” vs “parameter”, “returns” vs “produces”) across the doc comments you add.
- When summarizing code behavior, focus on why it matters: the effect, the invariants, and the contract with callers.
- If the existing code already has partial comments, expand them to cover the missing pieces (arguments, return types) rather than replacing good context.
- Use the `.cursor/commands/document-rust-code.md` note as the single source of truth for formatting and tone. Mention it if the user asks for guidance.

## References

- `.cursor/commands/document-rust-code.md` – Primary instructions that triggered this skill.
