Overview
Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
Discover nine practical rules for creating procedural macros in Rust in this 45-minute conference talk by Carl Kadie at Rust Linz, December 2022. Learn how to develop macros as normal projects, convert between strings, syntax trees, and literal code, create debuggable unit tests, and understand and manipulate Rust syntax trees. Explore the principles of elegant Rust API design and gain insights from the anyinput macro, which simplifies accepting various input types. Access accompanying slides and a free article in Towards Data Science for additional resources. By following these guidelines, transform the process of writing macros into an experience as straightforward as developing a regular Rust program that manipulates large, nested structs.
Syllabus
Nine Rules for Creating Procedural Macros in Rust
Talk's Approach: 9 "Rules"
Develop as a normal (non-macro) project
Convert freely: Strings, Syntax trees, Literal code
Create debuggable unit tests
Understand Rust syntax trees
Recursively manipulate syntax trees
Follow the rules of elegant Rust API design
Conclusion: Follow these 9 rules and ... writing macros as easy as writing a regular Rust program ... that manipulates large, nested structs.
Taught by
Rust