vin-macros 4.0.0

Procedural macros that power vin
Documentation
use proc_macro2::TokenStream as TokenStream2;
use syn::{Ident, Fields, Attribute};
use quote::quote;

use super::names::*;

pub fn form_vin_context_struct(name: &Ident, fields: &Fields, other_attrs: &Vec<&Attribute>) -> TokenStream2 {
    let context_struct_name = form_context_struct_name(name);

    match fields {
        Fields::Named(fields) => quote! {
            #(#other_attrs)*
            pub struct #context_struct_name #fields
        },
        Fields::Unnamed(fields) => quote! {
            #(#other_attrs)*
            pub struct #context_struct_name #fields;
        },
        Fields::Unit => quote! {
            #(#other_attrs)*
            pub struct #context_struct_name;
        }
    }
}