diff options
author | HampusM <hampus@hampusmat.com> | 2023-08-03 15:09:46 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-08-03 15:15:29 +0200 |
commit | a3ccc2713bb5315123814cadd6c50275eee38e1c (patch) | |
tree | 22d50e174f3181bbddfd50840408e85e5a4adaac /macros/src/declare_interface_args.rs | |
parent | 14f1fc1837675e1771e220f848b46213462ae804 (diff) |
feat: add constructor name flag to injectable macro
Diffstat (limited to 'macros/src/declare_interface_args.rs')
-rw-r--r-- | macros/src/declare_interface_args.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/macros/src/declare_interface_args.rs b/macros/src/declare_interface_args.rs index cf0dbce..79004da 100644 --- a/macros/src/declare_interface_args.rs +++ b/macros/src/declare_interface_args.rs @@ -30,7 +30,7 @@ impl Parse for DeclareInterfaceArgs let flags = Punctuated::<MacroFlag, Token![,]>::parse_terminated(input)?; for flag in &flags { - let flag_name = flag.flag.to_string(); + let flag_name = flag.name().to_string(); if !DECLARE_INTERFACE_FLAGS.contains(&flag_name.as_str()) { return Err(input.error(format!( @@ -41,7 +41,7 @@ impl Parse for DeclareInterfaceArgs } if let Some((dupe_flag, _)) = flags.iter().find_duplicate() { - return Err(input.error(format!("Duplicate flag '{}'", dupe_flag.flag))); + return Err(input.error(format!("Duplicate flag '{}'", dupe_flag.name()))); } flags @@ -64,9 +64,10 @@ mod tests use proc_macro2::Span; use quote::{format_ident, quote}; - use syn::{parse2, LitBool}; + use syn::{parse2, Lit, LitBool}; use super::*; + use crate::macro_flag::MacroFlagValue; use crate::test_utils; #[test] @@ -139,8 +140,11 @@ mod tests assert_eq!( decl_interface_args.flags, Punctuated::from_iter(vec![MacroFlag { - flag: format_ident!("async"), - is_on: LitBool::new(true, Span::call_site()) + name: format_ident!("async"), + value: MacroFlagValue::Literal(Lit::Bool(LitBool::new( + true, + Span::call_site() + ))) }]) ); |