
Rustacean Station Write Powerful Rust Macros with Sam Van Overmeire
10 snips
Jun 21, 2024 Meet Sam Van Overmeire, author of 'Write Powerful Rust Macros,' discussing macro security, interesting macros, and when to use macros. Learn about Rust macros intricacies and Manning Publishing's Rust books.
AI Snips
Chapters
Transcript
Episode notes
Macros Are Undercovered In Rust Books
- Macros are a deep, under-taught part of Rust that many books only briefly touch.
- Sam wrote his book to fill that gap with step-by-step examples and explanations.
Run Cargo Expand To See Macro Output
- Use cargo expand to reveal exactly what a macro generates and debug macro output.
- Inspecting expanded code helps diagnose surprising compiler errors caused by macros.
Test Macros With White And Black Box Tests
- Test macros both from the inside (token streams) and the outside (behavior) to catch regressions.
- Prioritize black-box tests that verify the macro does what users expect.
