Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is this really what Rust macros look like?


This 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

[2] https://doc.rust-lang.org/book/ch19-06-macros.html#procedura...


Yes, 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.


It 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/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: