I'm trying to create a Vec of TokenStreams, and then use that list in another quote! macro:
let list: Vec<_> = some_data
.iter()
.map(
|item| {
quote!{/*...*/}
},
)
.collect();
let generated = quote! {
fn hello_world() {
#(list);*
}
};
However, when compiling this, I'm getting this error:
expected struct `HasIterator`, found struct `ThereIsNoIteratorInRepetition`
From the macro's documentation, it seems that TokenStream should be valid in an interpolation, since it implements the ToTokens trait. Also, the list is a Vec, which is also explicitly allowed to be used in the loop interpolation.
Why am I getting the ThereIsNoIteratorInRepetition error when I am clearly using a valid iterator?