Problem / Solution Reference
Quick map from recurring problems to idiomatic Rust solutions and deeper articles.
Recipe
| Problem | Idiomatic solution |
|---|---|
| Parse CLI args | clap 4 derive |
| HTTP API | Axum 0.8 + tower |
| DB access | sqlx 0.8 with pool |
| JSON | serde 1.0 |
| Async runtime | Tokio 1.x |
When to reach for this: "How do I X in Rust?" during design or code review.
Working Example
Ownership and borrows
| Problem | Solution | Article |
|---|---|---|
| Borrow checker fight | restructure, Arc, lifetimes | Fighting the Borrow Checker |
| Shared read-only data | Arc<T> | Rc and Arc |
| Interior mutability | RefCell / Mutex | Interior Mutability |
Async and I/O
| Problem | Solution | Article |
|---|---|---|
| Blocking in async | spawn_blocking | 30 Async Rules |
| HTTP client | reqwest + shared client | HTTP Clients |
| Timeouts | tokio::time::timeout | Retries & Timeouts |
Data and perf
| Problem | Solution | Article |
|---|---|---|
| Tabular analytics | Polars 0.46+ lazy | Polars |
| Too many clones | borrow/Cow | Avoiding Clones |
| Slow release binary | LTO, features trim | Release Tuning |
Deep Dive
Add team-specific rows to internal wiki: auth (JWT crate), config (config + serde), observability (tracing + OpenTelemetry).
Gotchas
- Copying Java patterns - ORM-heavy anemic models. Fix: domain types + explicit repos.
- Stringly config - use typed config structs.
- Global singletons -
OnceLockor injected state. - unwrap culture - see error rules.
- wrong concurrency model - CPU on thread pool, I/O async.
Alternatives
| Alternative | Use When | Don't Use When |
|---|---|---|
| This reference | Quick routing | Deep learning substitute |
| ADR | Significant fork | Every small choice |
| AI search | Exploration | Sole authority |
FAQs
How extend table?
Add rows in PR when same question asked thrice in team chat.
ORM choice?
sqlx for control; SeaORM/Diesel per team preference - link database articles.
CLI?
clap 4 derive + anyhow in main.
testing?
nextest + tokio test + sqlx test fixtures.
auth?
JWT/oauth articles in api-auth-security section.
logging?
tracing structured JSON; tracing-subscriber env filter.
metrics?
metrics crate + Prometheus scrape endpoint.
deploy?
Minimal Docker + cargo build --release static or distroless.
FFI?
bindgen/cbindgen articles in systems-ffi.
WASM?
wasm-bindgen + wasm-pack flow in webassembly section.
Related
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+.