3 ms·
Is this really what Rust macros look like?
by MeetingsBrowser 2y ago
Is this really what Rust macros look like?
- C-programmer 2y agoYes, and I've seen them in production. Once you learn the rules, you can parse them reasonably well in your head but it is still really confusing at a glance.
- p4ul 2y agoThis is one kind of macro in Rust: declarative macros [1]. The other kind of macros in Rust are procedural macros [2]. Both are widely used in idiomatic Rust. And even within the procedural type of macros, there are different categories of macros (i.e., function-, or attribute-like macros). [1] https://doc.rust-lang.org/book/ch19-06-macros.html https://doc.rust-lang.org/book/ch19-06-macros.html [2] https://doc.rust-lang.org/book/ch19-06-macros.html#procedural-macros-for-generating-code-from-attributes https://doc.rust-lang.org/book/ch19-06-macros.html#procedura...
- CodeBrad 2y agoIt is! Although they are being used in a really weird and not normal way here. I found "The Little Book of Rust Macros"[1] to be a really good resource for getting started with Rust's declarative macros. [1]: https://veykril.github.io/tlborm/ https://veykril.github.io/tlborm/