fixed comma error for more complex structures
This commit is contained in:
parent
782dd07f64
commit
7de638f9da
16
src/lib.rs
16
src/lib.rs
@ -211,7 +211,7 @@ fn emit_section_struct(out: &mut proc_macro2::TokenStream, section: &ParseConfig
|
||||
let name = var.name.clone();
|
||||
let ty = var.ty.clone();
|
||||
quote! {
|
||||
pub #name: #ty
|
||||
pub #name: #ty,
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
let subsections = §ion.subsections.iter().map(|subsection| {
|
||||
@ -219,7 +219,7 @@ fn emit_section_struct(out: &mut proc_macro2::TokenStream, section: &ParseConfig
|
||||
let type_name_ident = Ident::new(type_name.as_str(), subsection.name.span());
|
||||
let var_name = subsection.name.clone();
|
||||
quote! {
|
||||
pub #var_name: #type_name_ident
|
||||
pub #var_name: #type_name_ident,
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
@ -229,8 +229,8 @@ fn emit_section_struct(out: &mut proc_macro2::TokenStream, section: &ParseConfig
|
||||
let struct_stream = quote! {
|
||||
#[derive(Debug)]
|
||||
pub struct #type_name_ident {
|
||||
#(#vars),*
|
||||
#(#subsections),*
|
||||
#(#vars)*
|
||||
#(#subsections)*
|
||||
}
|
||||
};
|
||||
|
||||
@ -248,7 +248,7 @@ fn emit_section_deser_impl(out: &mut proc_macro2::TokenStream, section: &ParseCo
|
||||
Ok (value) => value,
|
||||
Err (_config_deser::ConfigError::NotFound(_)) => #var_default,
|
||||
Err (x) => return Err(LFCMError::ParseError(x))
|
||||
}
|
||||
},
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
@ -258,7 +258,7 @@ fn emit_section_deser_impl(out: &mut proc_macro2::TokenStream, section: &ParseCo
|
||||
let subsection_type_name = Ident::new(capitalize_name(&subsection.name.to_string()).as_str(), subsection.name.span());
|
||||
let subsection_name_lit = Literal::string(subsection.name.to_string().as_str());
|
||||
quote!{
|
||||
#subsection_name: #subsection_type_name::deser(cfg, (prefix.to_owned() + #subsection_name_lit + ".").as_str())?
|
||||
#subsection_name: #subsection_type_name::deser(cfg, (prefix.to_owned() + #subsection_name_lit + ".").as_str())?,
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
@ -268,8 +268,8 @@ fn emit_section_deser_impl(out: &mut proc_macro2::TokenStream, section: &ParseCo
|
||||
impl #section_type_name_ident {
|
||||
fn deser(cfg: &_config_deser::Config, prefix: &str) -> Result<Self, LFCMError> {
|
||||
Ok (Self {
|
||||
#(#var_deser_parts,)*
|
||||
#(#subsection_deser_parts,)*
|
||||
#(#var_deser_parts)*
|
||||
#(#subsection_deser_parts)*
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user