Associated types in traits for cleaner generics

Associated types let a trait declare a type that implementors must define. This is cleaner than adding a generic parameter to the trait. For example, Iterator has an associated type Item rather than being Iterator<Item>. I use associated types w

impl Trait for opaque return types

impl Trait in return position lets you return a type that implements a trait without naming it. This is useful for closures, iterators, or futures where the concrete type is complex or unnameable. The caller only knows it implements the trait. I use i

const and const fn for compile-time evaluation

const defines compile-time constants, and const fn are functions that can run at compile time. I use const for magic numbers, lookup tables, and configuration that never changes. const fn is powerful for building complex constants (like hash maps or a

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

color-eyre for beautiful error reports with backtraces

color-eyre enhances eyre (an anyhow alternative) with colored, human-readable error messages and backtraces. It automatically captures panic backtraces and suggestion hints. I use it in CLI tools where error UX matters. The setup is minimal: color_eyr

nom for parser combinators and zero-copy parsing

Nom is a parser combinator library for building parsers from small, composable functions. It's byte-oriented and zero-copy, making it ideal for binary protocols, config files, or log parsing. I define parsers for tokens (like tag("GET") or digit1), th

Parking_lot for faster synchronization primitives

parking_lot provides drop-in replacements for Mutex, RwLock, and Condvar that are faster and smaller than std::sync. They use more efficient parking/unparking and don't poison on panic. I use parking_lot::Mutex in hot paths where lock contention matte

Crossbeam for advanced concurrent data structures

Crossbeam provides lock-free data structures and utilities for concurrent programming. The crossbeam-channel crate offers multi-producer multi-consumer channels with better performance than std::sync::mpsc. crossbeam-utils has scoped threads (borrow d

log crate facade for pluggable logging backends

The log crate provides logging macros (error!, warn!, info!, debug!, trace!) that are backend-agnostic. Libraries use log, and applications choose the backend (env_logger, simple_logger, or tracing). This decouples logging from the implementation. I u

panic! and unwinding for unrecoverable errors

Rust panics are for bugs, not expected errors. When code panics (via panic!, unwrap(), expect(), or assertion failure), the thread unwinds by default, running destructors. I use panic! for invariant violations or \"this should never happen\" cases. Fo

PhantomData for zero-cost type-level markers

PhantomData<T> is a zero-sized type that acts as if it owns T for the purposes of lifetimes, variance, and drop check. I use it in the typestate pattern or when a struct logically depends on T but doesn't store it. For example, a handle to an ex

Send and Sync traits for safe concurrency guarantees

Send means a type can be transferred across thread boundaries. Sync means a type can be shared between threads (&T is Send). Most types are Send + Sync; exceptions include Rc (not Send) and RefCell (not Sync). The compiler uses these marker traits