Mykhailo Maidan
Crafting Custom Frameworks with Rust: A Deep Dive into Procedural Macros
#1about 7 minutes
Exploring the power and pitfalls of Rust macros
Rust's metaprogramming capabilities allow for reducing boilerplate code, but macros can be complex to write, debug, and test.
#2about 6 minutes
Simplifying event handlers with custom attribute macros
An event-driven framework's API can be significantly simplified by using attribute macros to define event handlers and their corresponding events.
#3about 7 minutes
Overcoming unordered macro expansion with build-time metadata
To solve the problem of unordered macro expansion, a build script (`build.rs`) can analyze the source code and generate a metadata file before compilation.
#4about 8 minutes
Parsing crate source code with the `syn` crate
The `syn` and `syn-inline-mod` crates enable parsing an entire Rust crate into a single Abstract Syntax Tree (AST), which can then be analyzed using the visitor pattern.
#5about 5 minutes
Loading metadata and modifying the AST in macros
Procedural macros can load the pre-generated metadata from disk and use the `VisitMut` trait from `syn` to modify the AST, such as renaming functions to simulate overloading.
#6about 8 minutes
Evaluating the trade-offs of a metadata-driven macro framework
While this metadata-driven approach offers powerful compile-time checks and extensibility for tooling, it increases build times and implementation complexity.
#7about 12 minutes
Q&A on testing, nightly Rust, and framework design
The discussion covers practical considerations like the necessity of nightly Rust for certain features, strategies for testing complex macros, and potential runtime optimizations.
Related jobs
Jobs that call for the skills explored in this talk.
Featured Partners
Related Videos
Reasoning about Rust: an introduction to Rustdoc's JSON format
Luca Palmieri
A Love Letter to Rust
Rainer Stropek
Eternal Sunshine of the Spotless Programming Language
Stefan Baumgartner
Get ready to Rustle
Marco Otte-Witte
Rust and Docker: Let's build an AI-powered app!
Francesco Ciulla
Interface Contracts in Microfrontend Architectures
Alexander Günsche
Rust Beyond Systems: Revolutionizing Web Development
Patrick Koss
Microfrontends with Blazor: Welcome to the Party!
Florian Rappl
From learning to earning
Jobs that call for the skills explored in this talk.


Développeur Rust (IT)
Canton of Valence-4, France
Software Engineer (Python/Rust)
Realm
Charing Cross, United Kingdom
€54K
Intermediate
Python
FastAPI
PostgreSQL
Software Engineer (Rust development)
Randstad
Buochs, Switzerland
Intermediate
C++
Linux
RabbitMQ
Scripting (Bash/Python/Go/Ruby)
Lead Software Engineer - Rust
Tenth Revolution Group
Charing Cross, United Kingdom
€100-130K
Senior
DevOps
Python
Terraform
Kubernetes
+2


