Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Nine Rules for Creating Procedural Macros in Rust - Lecture

Rust via YouTube

Overview

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

Reviews

Start your review of Nine Rules for Creating Procedural Macros in Rust - Lecture

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.