Can quote! handle looping/repetition?

quote - Rust can handle unquote via #var_name. However, I don't see an obvious way for it to handle looping / repetition.

If I need some thing evaluated a variable number of time, can I do it directly in quote!, or do I have to build outside as TokenStream in proc_macro - Rust and merge them.

Concrete problem: suppose we want to do something that involves every field of a struct. Is this something we can do inside of quote!, (looping over every field), or is this something we have to do separately by building TokenStreams manually ?

Documentation for macro itself mentions syntax, similar to one used in declarative macros, i.e. #(#var)*, which accepts arbitrary iterables. Is this what you want?

1 Like

Exactly what I need. Thanks!

I missed this by one link -- searched for 'repetition' on the quote crate documentation page, but not on the quote! documentation page. :slight_smile:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.