I have a question if someone can maybe point me to some rust template engine(s) that can be used specifically for code generation (so essentially text output).
Preferably something that can be fed with e.g. structs, do conditionals like if/else/match, for-loops/iterations and alike over data in a type-safe way.
An example what I am looking for (the example here is for java) would be something like: https://github.com/fizzed/rocker/blob/master/docs/SYNTAX.md. The template language itself is very close to the normal java syntax, and works type-safe with java objects.
I don't mind whether the input for it is in separate files or embedded in some macros. As long as it's easy and simple to use and type-safe I would be happy.
In rust-analyzer, we started with using tera (which is just a template language for text) but then switched to quote! + rustfmt. It works well enough for our moderate needs. See