I am trying to create a procedural derive macro that creates methods for each field of a struct. I understand how I can create a constant number of methods within an invocation of my macro, but I am at loss when trying to create a Vec<TokenStream> and then concatenating that somehow.
For example, I have something like this:
// create some functions dynamically for each field
let functions: Vec<_> = fields.iter().map(|field| {
quote!{
fn #field(&mut self) -> String {
// ...
}
}
}).collect();
let generated_code = quote!{
impl Struct {
#functions
}
};