aboutsummaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
Diffstat (limited to 'macros')
-rw-r--r--macros/src/injectable/macro_args.rs34
1 files changed, 21 insertions, 13 deletions
diff --git a/macros/src/injectable/macro_args.rs b/macros/src/injectable/macro_args.rs
index 50d4087..1dd06f8 100644
--- a/macros/src/injectable/macro_args.rs
+++ b/macros/src/injectable/macro_args.rs
@@ -17,26 +17,34 @@ impl Parse for InjectableMacroArgs
{
fn parse(input: ParseStream) -> syn::Result<Self>
{
- let interface = input.parse::<TypePath>().ok();
+ let input_fork = input.fork();
- if interface.is_some() {
- let comma_input_lookahead = input.lookahead1();
+ let mut interface = None;
- if !comma_input_lookahead.peek(Token![,]) {
+ if input_fork.parse::<MacroFlag>().is_err() {
+ // Input doesn't begin with flags
+
+ interface = input.parse::<TypePath>().ok();
+
+ if interface.is_some() {
+ let comma_input_lookahead = input.lookahead1();
+
+ if !comma_input_lookahead.peek(Token![,]) {
+ return Ok(Self {
+ interface,
+ flags: Punctuated::new(),
+ });
+ }
+
+ input.parse::<Token![,]>()?;
+ }
+
+ if input.is_empty() {
return Ok(Self {
interface,
flags: Punctuated::new(),
});
}
-
- input.parse::<Token![,]>()?;
- }
-
- if input.is_empty() {
- return Ok(Self {
- interface,
- flags: Punctuated::new(),
- });
}
let flags = Punctuated::<MacroFlag, Token![,]>::parse_terminated(input)?;