Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 name = var.name.clone();
|
||||||
let ty = var.ty.clone();
|
let ty = var.ty.clone();
|
||||||
quote! {
|
quote! {
|
||||||
pub #name: #ty
|
pub #name: #ty,
|
||||||
}
|
}
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
let subsections = §ion.subsections.iter().map(|subsection| {
|
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 type_name_ident = Ident::new(type_name.as_str(), subsection.name.span());
|
||||||
let var_name = subsection.name.clone();
|
let var_name = subsection.name.clone();
|
||||||
quote! {
|
quote! {
|
||||||
pub #var_name: #type_name_ident
|
pub #var_name: #type_name_ident,
|
||||||
}
|
}
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
|
|
||||||
@ -229,8 +229,8 @@ fn emit_section_struct(out: &mut proc_macro2::TokenStream, section: &ParseConfig
|
|||||||
let struct_stream = quote! {
|
let struct_stream = quote! {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct #type_name_ident {
|
pub struct #type_name_ident {
|
||||||
#(#vars),*
|
#(#vars)*
|
||||||
#(#subsections),*
|
#(#subsections)*
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ fn emit_section_deser_impl(out: &mut proc_macro2::TokenStream, section: &ParseCo
|
|||||||
Ok (value) => value,
|
Ok (value) => value,
|
||||||
Err (_config_deser::ConfigError::NotFound(_)) => #var_default,
|
Err (_config_deser::ConfigError::NotFound(_)) => #var_default,
|
||||||
Err (x) => return Err(LFCMError::ParseError(x))
|
Err (x) => return Err(LFCMError::ParseError(x))
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}).collect::<Vec<_>>();
|
}).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_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());
|
let subsection_name_lit = Literal::string(subsection.name.to_string().as_str());
|
||||||
quote!{
|
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<_>>();
|
}).collect::<Vec<_>>();
|
||||||
|
|
||||||
@ -268,8 +268,8 @@ fn emit_section_deser_impl(out: &mut proc_macro2::TokenStream, section: &ParseCo
|
|||||||
impl #section_type_name_ident {
|
impl #section_type_name_ident {
|
||||||
fn deser(cfg: &_config_deser::Config, prefix: &str) -> Result<Self, LFCMError> {
|
fn deser(cfg: &_config_deser::Config, prefix: &str) -> Result<Self, LFCMError> {
|
||||||
Ok (Self {
|
Ok (Self {
|
||||||
#(#var_deser_parts,)*
|
#(#var_deser_parts)*
|
||||||
#(#subsection_deser_parts,)*
|
#(#subsection_deser_parts)*
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user