--- type: reference title: Rust description: Current best practices for Rust projects - cargo, editions, web frameworks, and tooling. tags: - rust - cargo - axum - bootstrap - engineering timestamp: 2026-08-11 verified: 2026-08-28 --- CUT # Rust This page covers current (2025/2026) best practices for Rust projects. ## Bootstrap Create a binary crate: ```bash cargo new my-app --bin ``` Create a library crate: ```bash cargo new my-lib --lib ``` New projects use the Rust 2024 edition by default. ## Tooling | Category | Tool | Notes | |----------|------|-------| | Toolchain | rustup | Install with the rustup script. | | Formatter | rustfmt | Run `cargo fmt`. | | Linter | clippy | Run `cargo clippy --all-targets --all-features`. | | Testing | `cargo test` | Unit tests in `#[cfg(test)]`, integration tests in `tests/`. | | Async runtime | tokio | The standard choice. | Use `cargo clippy -- -D warnings` in CI. ## Workspaces Use a Cargo workspace for projects with multiple crates. Declare members in the root `Cargo.toml`. ``` workspace-root/ ├── Cargo.toml └── crates/ ├── app/ └── core/ ``` ## Web Frameworks | Framework | Best For | Notes | |-----------|----------|-------| | Axum 0.8 | Most Rust web apps | Most popular. Tokio team. | | actix-web | High-throughput services | Slightly faster in benchmarks. | | Rocket | Developer experience | Excellent ergonomics. | Use Axum for new web services. ## Error Handling Use `thiserror` for library error types. Use `anyhow` for application-level errors. The `?` operator propagates errors. ## Desktop and WASM * Use Tauri 2 for cross-platform desktop apps with a web frontend. * Use `wasm-pack` and `wasm-bindgen` for WebAssembly. ## Related Technologies * serde and serde_json for serialization. * clap for command-line interfaces. * tracing and tracing-subscriber for structured logging. * sqlx for compile-time checked SQL. * tonic for gRPC. * criterion for benchmarks. ## Citations * [The Cargo Book](https://doc.rust-lang.org/cargo/) * [Axum](https://docs.rs/axum/) * [Tauri](https://v2.tauri.app/) ## See Also * [SDLC and Tooling](../sdlc.md) * [Go](go.md)