50 Rust Rules Every Specialist Should Follow
A master checklist across safety, API design, async, performance, and tooling. Use in reviews and onboarding.
Busca en todas las páginas de la documentación
A master checklist across safety, API design, async, performance, and tooling. Use in reviews and onboarding.
unsafe scope - isolate in small modules with # Safety docs.unwrap in library public API - return Result.? for error propagation - avoid nested match noise.try_from over lossy as casts - especially user input.unsafe_code in domain crates - single FFI crate exception documented.panic! for control flow - use Result or Option.checked_add for user-influenced arithmetic - or widen types.#[deny(warnings)] seriously on toolchain bumps - fix, do not silence globally.UserId not bare u64.clone - profile clones in hot paths.&str over String in arguments - take impl AsRef<str> when flexible.Cow at boundaries - borrow when possible, own when needed.enum State { Draft, Live } not two bools.From/TryFrom - standard conversion traits.Rc<RefCell> webs - redesign with ownership or channels.Send/Sync requirements - especially for generic bounds.spawn_blocking for sync I/O.tokio::sync::Mutex in async - not std::sync::Mutex across await.tokio::time::timeout.Send bounds on spawned tasks - 'static + Send.SeqCst by default everywhere.OnceLock config instead.#[tokio::test] - fake time with pause.Cargo.lock for apps - reproducible deploys.cargo clippy -D warnings - in CI.cargo fmt --check - zero style debate.as_, to_, into_ conventions.thiserror in libraries, anyhow in binaries - workspace policy.error.source() chain.#[serde(deny_unknown_fields)] on external input - when safe.cargo audit on schedule - supply chain hygiene.Teams ratchet; start with safety, errors, CI (1-10, 41-48).
CI, clippy.toml disallowed methods, CODEOWNERS on unsafe crate.
All listed rules are baseline specialist practice on this site.
Review yearly with Rust edition and team incidents.
Juniors focus 1-20; seniors own 21-50 and enforcement.
See section articles: unsafe, async, performance, error rules.
Document in ADR with owner and expiry date.
Use as interview rubric for systems Rust roles.
Rules align with clippy; clippy automates subset.
Starting point; team adds org-specific rules 51+.
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.
Revisado por Chris St. John·Última actualización: 19 jul 2026