Rust Tooling
A guide to Rust development tooling, adapted from the leonardomso/rust-skills catalog (MIT licensed — see NOTICE.md). Configuration best practices for linting and Cargo project/workspace structure.
Categories
Project Structure [MEDIUM]
Cargo workspace and module layout conventions that scale with crate size.
| Rule | Description |
|---|---|
| proj-bin-dir | Put multiple binaries in src/bin/ |
| proj-build-rs-minimal | Keep build.rs minimal, deterministic, and idempotent |
| proj-feature-additive | Design Cargo features as strictly additive |
| proj-flat-small | Keep small projects flat |
| proj-lib-main-split | Keep main.rs thin, put logic in lib.rs |
| proj-mod-by-feature | Organize modules by feature, not by type |
| proj-mod-rs-dir | Choose mod.rs or adjacent-file style consistently |
| proj-msrv-declare | Declare rust-version (MSRV) and check it in CI |
| proj-prelude-module | Provide a prelude module for common imports |
| proj-pub-crate-internal | Use pub(crate) to mark internal-only APIs |
| proj-pub-super-parent | Use pub(super) for parent-module-only visibility |
| proj-pub-use-reexport | Use pub use to flatten the public API |
| proj-workspace-deps | Inherit dependency versions from the workspace |
| proj-workspace-large | Use a Cargo workspace for multi-crate projects |
Linting (Clippy & rustc) [MEDIUM]
Configure clippy and rustc lint levels to catch bugs and style issues before review.
| Rule | Description |
|---|---|
| lint-cargo-metadata | Enable clippy::cargo for publishable crates |
| lint-cfg-check | Declare custom cfgs and enable unexpected_cfgs |
| lint-clippy-nursery-selected | Cherry-Pick clippy::nursery lints instead of the whole group |
| lint-deny-correctness | Deny clippy::correctness instead of warning |
| lint-missing-docs | Warn on missing_docs for public API surface |
| lint-pedantic-selective | Cherry-Pick clippy::pedantic lints instead of the whole group |
| lint-rustfmt-check | Enforce cargo fmt --check in CI |
| lint-unsafe-doc | Require SAFETY comments on unsafe blocks |
| lint-warn-complexity | Enable clippy::complexity to flag unnecessarily convoluted code |
| lint-warn-perf | Enable clippy::perf to catch avoidable inefficiencies |
| lint-warn-style | Enable clippy::style for idiomatic patterns |
| lint-warn-suspicious | Enable clippy::suspicious to catch likely bugs |
| lint-workspace-lints | Configure lints once at the workspace level |
Quick Reference
Project Structure
// src/main.rs -- thin entry point
use my_app::{run, Config};
fn main() -> anyhow::Result<()> {
let config = Config::from_env()?;
run(config)
}
// src/lib.rs -- the actual application logic, reachable from tests/
pub mod config;
pub mod database;
pub use config::Config;
Linting (Clippy & rustc)
# Root Cargo.toml
[workspace.lints.rust]
unsafe_code = "deny"
[workspace.lints.clippy]
unwrap_used = "deny"
expect_used = "warn"
# crate-a/Cargo.toml
[lints]
workspace = true
See Also
- rust-coding-standards - General Rust coding standards and best practices
- rust-testing - Test-writing best practices for Rust
- NOTICE - MIT attribution for content adapted from leonardomso/rust-skills