I have a struct like this:
struct Input {
key1: u32,
key2: String,
value1: u16,
value2: u8
}
I want to write a proc macro using quote
that generates this struct:
struct InputKey {
key1: u32,
key2: String,
}
How do I do this?
The most I could figure out is this:
let ident_key_type = quote::format_ident!("{}Key", ident);
quote! {
pub struct #ident_key_type {
}
}
This is creating an empty struct.
I am unable to figure out how to write a for-loop to iterate over the 2 key fields "Key1" and "key2" and add those 2 fields to the InputKey struct.
My code uses the quote
library so I would prefer a solution that uses that.