Crafting Custom Frameworks with Rust: A Deep Dive into Procedural Macros
What if your Rust macros could share context across your entire crate? Learn how a pre-compilation metadata pass unlocks powerful, boilerplate-free APIs.
#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.
Matching moments
03:38 MIN
Q&A on ecosystem integration and custom metadata
Reasoning about Rust: an introduction to Rustdoc's JSON format
01:46 MIN
The future of Rust in modern web development
Get ready to Rustle
01:33 MIN
Implementing observability with metrics and distributed tracing
Rust Beyond Systems: Revolutionizing Web Development
01:56 MIN
Building an AI-powered app with Rust and Docker
Coffee with Developers - Francesco Ciulla
05:42 MIN
Practical strategies for adopting Rust in your projects
Get ready to Rustle
01:29 MIN
A strategic approach to teaching Rust on YouTube
Coffee with Developers - Francesco Ciulla
06:10 MIN
The limitations of macros for static analysis
Reasoning about Rust: an introduction to Rustdoc's JSON format
02:15 MIN
Understanding why frameworks were created for human teams
Are frameworks like React redundant in an AI world?
4 reasons why you should learn Rust in 2021 – and maybe even have fun doing itRust is considered complex and a programming language with a steep learning curve. That's one side of the medal. We mention four points that Rust has ahead of other programming languages in terms of user-friendliness. Rust is a modern programming lan...
Daniel Cranney
Building AI Solutions with Rust and DockerIn recent years, artificial intelligence has surged in popularity in the world of development. While Python remains a popular choice in the realm of AI, Rust - often known as Rust Lang - is quickly emerging as a formidable alternative.Rust programmin...
Chris Heilmann
WeAreDevelopers LIVE days are changing - get ready to take partStarting with this week's Web Dev Day edition of WeAreDevelopers LIVE Days, we changed the the way we run these online conferences. The main differences are:Shorter talks (half an hour tops)More interaction in Q&AA tips and tricks "Did you know" sect...
Chris Heilmann
Processing 175 WeAreDeveloper World Congress talk videos in 5 hours - with PHP?Every year after the WeAreDevelopers World Congress is over, we have a ton of video footage to edit and release. Most of it is in raw format and needs editing by hand, but a lot of our sessions are also streamed live on YouTube and thus easier to re-...
From learning to earning
Jobs that call for the skills explored in this talk.