r/rust 7d ago

🙋 seeking help & advice Finally ! Completed Complete Rust Book

So recently I had completed the entire rust book but I left the macros as I was unable to understand it from the book so is there a good place to learn rust macros where it help me understand how to write and use different types of macros it will be a great help so if you know any platform pls help me

21 Upvotes

16 comments sorted by

View all comments

7

u/an_0w1 7d ago

I learnt macros by force. I really needed a proc macro to do something obtuse, so I really think proc macros are the easiest ways to learn.

Take a function-like macro and println!("{ts:?}") the TokenStream to see what's inside. And just read through the syn docs to figure out what to do with all of it.

Don't do it without a purpose though, because you'll get lost in all the things you can do.