Rust Coding Practices
Application skill for Rust style learning (from the archived awesome-guidelines style capsules). For async/concurrency or framework crates, combine with stack-specific guidance.
Core Principle
Follow the project rustfmt, lint, and API conventions. The retained API-guideline
capsules are options for predictable public surfaces, not universal requirements
for every type or private helper.
When to Use / NOT
- Rust library/application code, public API design, CI setup.
- Reviewing
Result types, error enums, or rustdoc.
NOT when:
- Non-Rust code.
- Macro-heavy generated code, validate generator output, not hand-edits.
Workflow
- Format & names,
cargo fmt, casing, conversion prefixes (rust-style-formatting-naming.md).
- Errors, choose useful error information for callers. Add
Error, Send,
or Sync bounds where consumers/runtime boundaries require them; a local
sentinel error can be enough (rust-style-errors-result.md).
- Interop, common traits,
From, iterator naming (rust-style-traits-interop.md).
- API shape, methods,
new, no out-params, Deref discipline, docs (rust-style-api-predictability.md).
- Verify,
cargo fmt --check, cargo clippy, cargo test --doc.
Red Flags
Result<T, ()> losing distinctions a caller needs
unwrap() in public docs
get_* on ordinary field getters
Deref on domain wrapper for . syntax sugar
- Manual formatting vs rustfmt
- Missing useful diagnostics on public types, or diagnostics exposing secrets
Verification
cargo fmt --check, cargo clippy -- -D warnings (project policy)
- Doctests pass with
? pattern
- Capsule checklist on public API review
References
awesome-guidelines/references/rust-style-learning-note.md
awesome-guidelines/references/rust-style-formatting-naming.md
awesome-guidelines/references/rust-style-errors-result.md
awesome-guidelines/references/rust-style-traits-interop.md
awesome-guidelines/references/rust-style-api-predictability.md
1---2name: rust-coding-practices3description: Use when authoring or reviewing Rust, rustfmt defaults, RFC 430 naming, meaningful Error types, Result/? in docs, common trait impls, iter/into_iter conventions, and predictable public APIs.4---56# Rust Coding Practices78Application skill for Rust style learning (from the archived `awesome-guidelines` style capsules). For async/concurrency or framework crates, combine with stack-specific guidance.910## Core Principle1112Follow the project rustfmt, lint, and API conventions. The retained API-guideline13capsules are options for predictable public surfaces, not universal requirements14for every type or private helper.1516## When to Use / NOT1718- Rust library/application code, public API design, CI setup.19- Reviewing `Result` types, error enums, or rustdoc.2021**NOT when:**2223- Non-Rust code.24- Macro-heavy generated code, validate generator output, not hand-edits.2526## Workflow27281. **Format & names**, `cargo fmt`, casing, conversion prefixes (`rust-style-formatting-naming.md`).292. **Errors**, choose useful error information for callers. Add `Error`, `Send`,30 or `Sync` bounds where consumers/runtime boundaries require them; a local31 sentinel error can be enough (`rust-style-errors-result.md`).323. **Interop**, common traits, `From`, iterator naming (`rust-style-traits-interop.md`).334. **API shape**, methods, `new`, no out-params, Deref discipline, docs (`rust-style-api-predictability.md`).345. **Verify**, `cargo fmt --check`, `cargo clippy`, `cargo test --doc`.3536## Red Flags3738- `Result<T, ()>` losing distinctions a caller needs39- `unwrap()` in public docs40- `get_*` on ordinary field getters41- `Deref` on domain wrapper for `.` syntax sugar42- Manual formatting vs rustfmt43- Missing useful diagnostics on public types, or diagnostics exposing secrets4445## Verification4647- `cargo fmt --check`, `cargo clippy -- -D warnings` (project policy)48- Doctests pass with `?` pattern49- Capsule checklist on public API review505152## References5354- `awesome-guidelines/references/rust-style-learning-note.md`55- `awesome-guidelines/references/rust-style-formatting-naming.md`56- `awesome-guidelines/references/rust-style-errors-result.md`57- `awesome-guidelines/references/rust-style-traits-interop.md`58- `awesome-guidelines/references/rust-style-api-predictability.md`