proc-macro-workshop is an educational resource for learning to write Rust procedural macros.
The workshop addresses the challenge of understanding how to generate Rust code programmatically through macros. It teaches this through five hands-on projects that progress from foundational concepts to more complex implementations. Each project is grounded in real-world use cases: three are macros the author has implemented in production codebases, and two are existing libraries published on crates.io. The projects cover derive macros, function-like macros, and attribute macros, teaching developers how to traverse syntax trees, construct output source code, and process helper attributes.
The workshop suits developers who already understand Rust fundamentals like structs, enums, traits, trait implementations, generic parameters, and trait bounds. The five projects are the `derive(Builder)` macro for implementing the builder pattern, the `derive(CustomDebug)` macro for customizable Debug trait implementations, the `seq!` function-like macro, the `#[sorted]` attribute macro, and the `#[bitfield]` attribute macro. Each project goes into depth beyond its introduction and includes a test harness for validation. The workshop provides project recommendations based on developer interests and includes debugging tips to support the learning process.
The project maintains a structured approach with clear prerequisites, a recommended workflow, and organized project directories. The material assumes learners will work through the projects sequentially or select based on their specific interests in macro types. The workshop includes explanations of testing setup and provides guidance on how to approach each exercise effectively.