Skip to content

Commit

Permalink
fix: allow the macro to support enums without subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Dec 26, 2022
1 parent 40742d1 commit 3ddd529
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/tailwind-parse-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ pub fn parser(_attr: TokenStream, input: TokenStream) -> TokenStream {
.collect::<Vec<_>>();

let has_subsegments = has_subsegments.iter();
let subcommands_true = if subcommands.is_empty() {
quote! {}
} else {
quote! {#(#name::#subcommands(_))|* => true, }
};

TokenStream::from(quote! {
mod plugin {
Expand All @@ -161,7 +166,7 @@ pub fn parser(_attr: TokenStream, input: TokenStream) -> TokenStream {

pub fn has_subcommand(&self) -> bool {
match self {
#(#name::#subcommands(_))|* => true,
#subcommands_true
_ => false
}
}
Expand Down

0 comments on commit 3ddd529

Please sign in to comment.