rust-conventionslisted
Install: claude install-skill qol-tools/qol-skills
# Rust Guidelines
## Cross-Platform Support
Platform-specific code should be isolated in dedicated modules:
- Use `platform/` subdirectories for OS-specific implementations
- Keep main modules free of `#[cfg(target_os)]` conditionals when possible
- All platform differences should be handled at the platform abstraction layer
- For structured cross-platform compartmentalization (strategy pattern, platform/ subfolders), see the `qol-arch-code` skill
- For symbol/import hygiene that prevents `dead_code`/`unused_imports` errors on the OSes you don't usually develop on, see `qol-arch-cross-platform`
- For the CI/release workflow contract that catches what the static checks miss, see `qol-arch-cicd`
## Type Safety
- **Newtypes for domain concepts** - `struct PluginId(String)`, not raw `String`.
- **Make invalid states unrepresentable** - model state machines with enums, not
a bool flag plus an optional field that only means something when the flag is set.
- **Parse, don't validate** - parse into validated types at the boundary and use
those types internally, instead of re-checking a raw value at every call site.
- **Exhaustive matching** - match all enum variants explicitly. No `_ =>` arm, so
the compiler catches every new variant.
- A wildcard is not a style preference: it converts a compile error into a
silent runtime default. Enumerating the remaining variants by name
(`View::Logs | View::Trace | ... => ...`) costs one line and keeps the guard.
- This appli