Skip to content

Added support for variant-attributes, updated README to show the syntax - #23

Closed
philipp-haker wants to merge 2 commits into
greyblake:masterfrom
philipp-haker:master
Closed

Added support for variant-attributes, updated README to show the syntax#23
philipp-haker wants to merge 2 commits into
greyblake:masterfrom
philipp-haker:master

Conversation

@philipp-haker

Copy link
Copy Markdown

This pull Request would resolve #22.
It adds support for zero or more attributes on variants, contained in a #[kinded(attr)]. For each of these a #[attr] will be created for the corresponding variant of the kind-enum.

These Changes were made:

  • In kinded_macros/src/moodels.rs the Variant-struct got a new field kinded_variant_attrs that contains the attributes that should put on the variant of the kinde-enum.
  • In kinded_macros/src/parse.rs a function was created that parses the attributes
  • In kinded_macros/src/generate/kind_enum.rs these attributes were written to the generated variants.
  • In test_suite a dependency for strum was added and a test was introduced. The EnumMessage derive succeeds even if there are no attributes to configure it present. These attributes just change the returned values. As such the test will always compile, but fail if the variant attributes are not present.
  • In README.md (top-level) an example was added that creates small documentation for the kind-enum variants and derives Default for it.

@greyblake

Copy link
Copy Markdown
Owner

I am closing this in favor: #27

I decided to use attrs() sub-attribute for variants to stay consist, since attrs() can be used already on a enum type

@greyblake greyblake closed this Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for variant attributes

2 participants