1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![no_std]
use proc_macro::TokenStream;
use quote::quote;
use syn::parse_macro_input;

mod structs;

#[proc_macro]
pub fn structs_new(input: TokenStream) -> TokenStream {
    use structs::NewItemStruct;
    let new_structs = parse_macro_input!(input with NewItemStruct::parse_multi);
    let expand = new_structs.into_iter()
                            .map(NewItemStruct::split)
                            .map(|(item_struct, item_impl)| quote! {#item_struct #item_impl});
    TokenStream::from(quote! { #(#expand)* })
}