1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use syn::*;
use quote::*;

#[proc_macro_derive(ToDeriveInput)]
pub fn derive_to_derive_input(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
    let derive_input = parse_macro_input!(input as DeriveInput);
    let ty_name = derive_input.ident.clone();

    quote! {
        use to_syn_value::*;

        impl ToDeriveInput for #ty_name {
            fn to_derive_input() -> syn::DeriveInput {
                syn::parse_quote! {
                    #derive_input
                }
            }
        }
    }.into()
}