A gentle introduction to procedural macros
summary
Gentle, practical intro that claims to go from basics to a working derive macro that simplifies (AWS) SQS send/receive; includes live coding that builds a generated client struct with new/send/receive methods and demonstrates it running against localstack and the aws SDK under tokio. Shows parsing via syn and quote inside a separate proc-macro crate, uses format_ident to generate names, and inspects output with cargo expand so the demo actually compiles and works.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 2:35Rust macros and why use them
- 5:23Procedural macros in Rust
- 7:52Power and use cases
- 8:14Live demo setup
- 11:23Procedural macro crate
- 12:25Basic derive macro function
- 13:52Verify macro expansion
- 16:01Generating boilerplate
- 18:51Limits of hardcoded output
- 19:33Inspecting token streams
- 20:36Parsing derive inputs
- 21:40Analyzing input structure
- 22:46Making macro generic
- 24:15Testing macro implementation
- 24:57When to use macros
- 27:02Summary
related talks
29mMacromancy: an introduction to Rust macros
39mRust metaprogramming - macro_rules! beyond basics
29mProcedural Macros vs Sliced Bread
24mMacros for a More Productive Rust
26mMaking life easier with Derive and other tools
18mImpractical Macros
26mMy Little Procedural Macro
31mFunctional programming guerilla in the land of Rust
