diff --git a/perlmod-macro/src/attribs.rs b/perlmod-macro/src/attribs.rs index 35e61f9..1f6edfc 100644 --- a/perlmod-macro/src/attribs.rs +++ b/perlmod-macro/src/attribs.rs @@ -7,6 +7,7 @@ pub struct ModuleAttrs { pub package_name: String, pub file_name: Option, pub lib_name: Option, + pub write: Option, } fn is_ident_check_dup(path: &syn::Path, var: &Option, what: &'static str) -> bool { @@ -27,6 +28,7 @@ impl TryFrom for ModuleAttrs { let mut package_name = None; let mut file_name = None; let mut lib_name = None; + let mut write = None; for arg in args { match arg { @@ -45,6 +47,17 @@ impl TryFrom for ModuleAttrs { error!(path => "unknown argument"); } } + syn::NestedMeta::Meta(syn::Meta::NameValue(syn::MetaNameValue { + path, + lit: syn::Lit::Bool(litbool), + .. + })) => { + if is_ident_check_dup(&path, &write, "write") { + write = Some(litbool.value()); + } else { + error!(path => "unknown argument"); + } + } _ => error!(Span::call_site(), "unexpected attribute argument"), } } @@ -56,6 +69,7 @@ impl TryFrom for ModuleAttrs { package_name, file_name, lib_name, + write, }) } } diff --git a/perlmod-macro/src/module.rs b/perlmod-macro/src/module.rs index 6df7928..9b5843f 100644 --- a/perlmod-macro/src/module.rs +++ b/perlmod-macro/src/module.rs @@ -68,8 +68,8 @@ pub fn handle_module(attr: AttributeArgs, mut module: syn::ItemMod) -> Result