Complex proc macros absolutely do slow builds down. In many cases, a proc macro only need to be a stub that can delegate to a declarative macro.
You may not need to use syn/quote, but if you are doing any sort of processing/parsing of Rust code you pretty much need to.
FWIW, I really hope that the Rust project focused on finer-grained token matching in declarative macros so we can migrate most proc_macro code away. The macro system is powerful, but nowhere near where it needs to be.
Most of the proc macros non-sense is to be able to annotate the enum or struct without wrapping it.
So that is why I use this hack:
https://docs.rs/macro_rules_attribute/0.2.2/macro_rules_attr...
P.D: Is there a true actually reason for proc-macros apart for this weird restriction?? And even if yes, how much nice things will be if this kind of scenario was already present so most not need to reach for proc-macros
The macro explained in that section was mainly for me to learn macros, and save up some boilerplate with nice syntax.
It's surprising how little information exists out there about proc_macros in general.
Couldn't agree more, both on proc macros and operating system, I did not find sufficient information on the internet. That is exactly the purpose of this book.
While there were alternatives with 3rd party libraries, the goal of the project is to implement and learn as much as I can.
Most of the guides I found online explained the concept great, but created only a simple macro as an example. So I decided to write about it myself too, with a real usage to create a bitfields attribute proc-macro, that takes a struct and turns it into bitfields.
Hope you will have a great read!