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.
Ask episode
AI Snips
Chapters
Transcript
Episode notes
INSIGHT

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.
ADVICE

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.
ADVICE

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.
Get the Snipd Podcast app to discover more snips from this episode
Get the app