Atomic operations for lock-free concurrency

For high-performance concurrent code, atomics provide lock-free synchronization. The std::sync::atomic module has AtomicBool, AtomicUsize, etc., with operations like load, store, fetch_add, and compare_exchange. These compile to CPU-level atomic instr

Unsafe Rust for FFI and low-level optimizations

Unsafe Rust lets you bypass some of the compiler's safety checks when necessary. Common uses include FFI (calling C code), dereferencing raw pointers, and implementing low-level data structures. The unsafe keyword creates a boundary where you promise

Criterion for benchmarking with statistical analysis

Criterion is the standard benchmarking library for Rust. It runs benchmarks multiple times, detects outliers, and reports statistical confidence intervals. The API is simple: wrap your code in a closure, and criterion measures execution time. It gener

Integration tests in tests/ directory

Integration tests go in the tests/ directory and are compiled as separate binaries. Each file in tests/ is a separate test crate with access only to your crate's public API. This enforces API-level testing and catches issues that unit tests miss. I us

Unit tests with #[test] and assert macros

Rust's built-in test framework is simple and powerful. Mark functions with #[test], and cargo test runs them. Use assert!, assert_eq!, and assert_ne! for assertions. Tests live alongside code in the same file, typically in a #[cfg(test)] mod tests blo

Feature flags for conditional compilation

Cargo's feature flags let you enable or disable parts of your crate at compile time. I use them for optional dependencies (like serde), platform-specific code, or different build profiles. Features are defined in Cargo.toml and checked with #[cfg(feat

Cargo workspaces for multi-crate projects

For larger projects, I organize code into multiple crates within a Cargo workspace. The root Cargo.toml lists workspace members, and each crate has its own dependencies and Cargo.toml. This lets you split code into libraries and binaries, share code b

sqlx for compile-time checked SQL queries with async

Sqlx is a pure-Rust SQL client that checks queries at compile time against your database schema. The query! macro connects to your DB during compilation and validates that columns and types match. This catches typos and schema drift before runtime. It

Tower middleware for composable HTTP service layers

Tower is a library of modular middleware (called "layers") for async services. Axum is built on Tower, so you can use any Tower middleware: TimeoutLayer, CompressionLayer, TraceLayer, etc. Layers wrap services, adding behavior like logging, metrics, o

axum for type-safe async HTTP servers

Axum is a modern web framework built on tokio and hyper. It uses extractors (like Json<T>, Path<T>, State<S>) to parse requests into Rust types, and the compiler ensures your handlers match their routes. Middleware is just functions,

reqwest for async HTTP client with connection pooling

Reqwest is the most popular async HTTP client for Rust. It's built on tokio and hyper, with a high-level API for making requests. Connection pooling, redirects, timeouts, and TLS are handled automatically. I use the builder pattern to configure client

serde for zero-copy serialization and deserialization

Serde is Rust's serialization framework, supporting JSON, YAML, TOML, MessagePack, and more through format-specific crates. With #[derive(Serialize, Deserialize)], your structs automatically convert to and from these formats. Serde is extremely fast b