structural-typing-macros 0.1.0

Procedural macros for structural-typing crate
Documentation
use proc_macro2::TokenStream;
use quote::quote;

use crate::parsing::StructInfo;

pub fn generate(info: &StructInfo) -> TokenStream {
    let struct_name = &info.name;
    let field_names = info.fields.iter().map(|f| &f.name);

    quote! {
        impl #struct_name {
            /// Creates an empty instance with all fields absent.
            pub fn empty() -> Self {
                Self {
                    #(#field_names: ::core::marker::PhantomData),*
                }
            }
        }
    }
}