rust

Type state pattern for compile-time state machines

The typestate pattern uses Rust's type system to encode state machines, making invalid states unrepresentable. Each state is a separate type, and transitions consume self and return a new state. The compiler prevents calling methods that aren't valid

async/await with tokio for concurrent I/O without blocking threads

Rust's async/await syntax lets you write asynchronous code that looks synchronous. An async fn returns a Future, which is a lazy computation. Calling .await yields control until the future is ready, allowing other tasks to run. Tokio is the most popul

Procedural macros for custom derives and attributes

Procedural macros operate on Rust syntax trees, enabling custom #[derive(...)], attribute macros, or function-like macros. I write proc macros for boilerplate reduction: auto-generating builders, serialization, or validation. They're more powerful tha

Inline assembly for critical performance hotspots

Rust's inline assembly (asm! macro) lets you write assembly for performance-critical code or to access hardware features. It's an unstable feature (nightly only) and requires unsafe. I use it sparingly for SIMD intrinsics not exposed by std::arch, cry

Sized trait and ?Sized for dynamically-sized types

Most types in Rust are Sized (known size at compile time), which is an auto trait. Some types like str or [T] are !Sized (dynamically-sized types, DSTs). To work with DSTs, use &T or Box<T>. In generic code, T: Sized is the default bound. To

mod and pub for code organization and visibility

Rust's module system uses mod to define modules and pub to control visibility. Modules can be inline (mod name { ... }) or in separate files (mod name; loads name.rs). By default, items are private; use pub to expose them. I organize code into modules