Skip to content

Commit bd8223c

Browse files
committed
fix: proc-macro properly generated VARIANTS field when enabled
The feature had no effect, because the condition was quoted out.
1 parent 1707a3c commit bd8223c

File tree

1 file changed

+16
-3
lines changed
  • enum-collections-macros/src

1 file changed

+16
-3
lines changed

enum-collections-macros/src/lib.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,30 @@ pub fn derive_enum_collections(input: TokenStream) -> TokenStream {
2929
variants.extend(quote! { Self::#variant_name, });
3030
}
3131

32-
quote! {
32+
#[cfg(feature = "variants")]
33+
return quote! {
3334
impl #generics Enumerated for #name #generics {
3435

3536
fn position(self) -> usize {
3637
self as usize
3738
}
3839

3940
const SIZE: usize = #enum_len;
40-
#[cfg(feature = "variants")]
4141
const VARIANTS: &'static [Self] = &[#variants];
4242
}
4343
}
44-
.into()
44+
.into();
45+
46+
#[cfg(not(feature = "variants"))]
47+
return quote! {
48+
impl #generics Enumerated for #name #generics {
49+
50+
fn position(self) -> usize {
51+
self as usize
52+
}
53+
54+
const SIZE: usize = #enum_len;
55+
}
56+
}
57+
.into();
4558
}

0 commit comments

Comments
 (0)