@lixou I think what you want is a [derive macro](https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros), which is a form of procedural macro.
There is a [proc macro workshop](https://github.com/dtolnay/proc-macro-workshop#attribute-macro-sorted) that will teach you a lot about writing proc macros. The author of the repo had also implemented some of the workshop items, such as [seq](https://github.com/dtolnay/seq-macro), which you can use as reference.
