Laravel form requests for validation

Form requests encapsulate validation logic in dedicated classes, keeping controllers thin and focused. Each form request extends FormRequest and defines rules() and optionally authorize() methods. The authorize() method checks if the user can perform

Laravel service container and dependency injection

Laravel's service container manages class dependencies and performs dependency injection automatically. When type-hinting interfaces or classes in constructors, Laravel resolves them from the container. I bind interfaces to implementations in service

Laravel Eloquent relationships with eager loading

Eloquent ORM makes working with database relationships intuitive and powerful. I define relationships using methods like belongsTo, hasMany, and belongsToMany that return query builders. The beauty of Eloquent is lazy loading—relationships load only w

std::mem helpers for low-level memory manipulation

The std::mem module provides utilities for working with memory: size_of, align_of, swap, replace, take, drop, forget, and transmute. I use mem::swap to exchange values without cloning, mem::replace to take a value out of a mutable reference, and mem::

MaybeUninit for safe uninitialized memory

MaybeUninit<T> is the safe way to work with uninitialized memory. It's useful for FFI, performance-critical code, or when you need to initialize large arrays element-by-element. Unlike uninitialized variables (which are UB), MaybeUninit is expli

cargo-expand to inspect macro expansions

cargo expand is a subcommand that shows the output of macro expansion. It's invaluable for debugging derive macros, understanding what declarative macros produce, or learning how async functions desugar. I run cargo expand --lib to see the entire crat

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

Build scripts (build.rs) for compile-time code generation

A build.rs file runs before compiling your crate, enabling code generation, FFI binding generation, or environment checks. I use build scripts to generate Rust code from proto files (with prost), compile C libraries, or set cfg flags based on the targ

tempfile for safe temporary file creation

The tempfile crate creates temporary files and directories that are automatically cleaned up on drop. I use it in tests, build scripts, and anywhere I need scratch space. tempfile::NamedTempFile gives you a file path, while tempfile::tempfile() create

std::process::Command for spawning external processes

std::process::Command runs external programs and captures their output. I use it for CLI tools that wrap other commands, build scripts, or integration tests. Methods like .arg(), .env(), and .current_dir() configure the process. .output() runs and wai

AsRef and AsMut for flexible function parameters

AsRef<T> is a trait for cheap reference-to-reference conversion. It's commonly used in function parameters to accept multiple types. For example, a function taking impl AsRef<Path> can accept &Path, PathBuf, &str, or String. This i

Deref and DerefMut for smart pointer ergonomics

Implementing Deref lets your type automatically coerce to its target type. For example, Box<T> derefs to T, and String derefs to str. This enables method calls and conversions without explicit unwrapping. I implement Deref for wrapper types and