3 ms·
Procedural macros take a list of tokens, and you give a list of tokens back, and they're then compiled. https://doc.rust-lang.org/stable/book/ch19-06-macros.ht
by steveklabnik 7y ago
Procedural macros take a list of tokens, and you give a list of tokens back, and they're then compiled.
https://doc.rust-lang.org/stable/book/ch19-06-macros.html#how-to-write-a-custom-derive-macro https://doc.rust-lang.org/stable/book/ch19-06-macros.html#ho... (starts with derive, then moves on to attributes. Function-like ones aren't stable yet)
- vbezhenar 7y agoThanks, that's similar, also I would argue that for inexperienced developer just producing desired text would be a simpler solution (but dangerous).
- TheCoelacanth 7y agoIf you use the `quote` crate[1], it's pretty much identical in terms of developer experience. [1] https://github.com/dtolnay/quote https://github.com/dtolnay/quote