Skip to content
0:00 / 0:00

#rust#proceduralmacros#proc-macro

Procedural Macros in Rust (part 2)

Jon Gjengset

111K subscribers • 38 videos on Hallway

YouTube

Advanced. Deep dive for people who know the field.

13K views7 years ago3 recommendations

Programming languagesRustLanguage design and type systems

Jon Gjengset continues working through David Tolnay's procedural macro workshop, implementing the seq and sorted macros in Rust.

In this stream, we dive deeper into Rust's procedural macros, following on from the previous stream. We continue to follow David Tolnay's excellent proc-macro workshop from Rust Latam back in March 2019: github.com/dtolnay/proc-macro-workshop, and go for the seq! and #[sorted] proc-macros! You can find my Amazon Wish List at amazon.com/hz/wishlist/ls/EI8GP25AL8FU?ref_=wl_share. You can find the code over at github.com/jonhoo/proc-macro-workshop. And you can see the live version with comments at youtube.com/watch?v=6XRCXJhO-QE

Why it's here

3 people recommend this

What people say. Recommended as a highly detailed, step-by-step walkthrough of building complex procedural macros in Rust.

Moments people linked to

u/420goonsquad420in r/rust • Recommends

On “Talk to me about macros”

…Rust proc macros are a whole different world. They let you execute arbitrary code at compile time, meaning you can make up syntax, run it through a proc macro, and have it spot out Rust code at the end. It's also how traits can be derived. Proc macros are magic. If you want to learn more, I'd personally recommend Jon Gjengset's video(s) on them: link to this video link to this video link to this video Note that this is collectively about 10 hours of video, so buckle in.…

u/fear_the_morrokin r/rust • Recommends

On “Resources for writing good proc-macros?”

In addition to this, Jon Gjengsets accompanying videos, where he walks through some of the workshop exercises is very helpful. part 1 part 2

u/MasterTextmanin r/rust • Recommends

On “Tablefy - my first crate!”

I would say that so far it was the hardest part of Rust I've touched, but even then it was still manageable! The most troublesome bit is that I couldn't find much helping material on how to make one, only to start one. What really helped were these two videos, where you see a procedural macro being built bit by bit. You can follow the workshop in the description and the video, and you'll get a pretty good gist of how to make one. It mostly consists of going through and forming new code from a destructured AST. This is all for *procedural macros,* there are other kinds that I haven't touched yet so far, but all in due time!
2View on Reddit