Copy fields of other structure?

Is there any crate or functionality that allows me to copy the fields from another structure?

Example

//Crate a
struct Product{
    name:String,
    sku:String,
    amount: i32,
    
} 

//Crate b
#[derive(copy_fields_from="a::Product", InputObject)]
struct ProductApi
 

I have to expose through an api several objects that are in another create using
"# [derive (InputObject)]", for that I have to duplicate all the structures of the other box, is it possible to copy the fields of another structure? example #[derive(copy_fields_from="a::Product")]

No, it's not possible. Macros can only see the text directly given to it, and the Product struct is not annotated with that macro, so its not possible to write a macro that can look up the fields of Product.

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.