Compare commits
No commits in common. "main" and "v0.1.0" have entirely different histories.
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lfcm"
|
||||
version = "0.1.0"
|
||||
version = "0.0.0"
|
||||
authors = ["Linus Vogel <linus@linvogel.ch>"]
|
||||
description = "A `cargo generate` template for quick-starting a procedural macro crate"
|
||||
keywords = ["template", "proc_macro", "procmacro"]
|
||||
|
||||
14
src/lib.rs
14
src/lib.rs
@ -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,)*
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ config! {
|
||||
param name = Config;
|
||||
section top {
|
||||
var rand: u64 = 42;
|
||||
var funny: i64 = 24;
|
||||
section database {
|
||||
var seed: u64 = 42;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user