Matrix of possible enum helpers and for which enums they can be generated.
------------------------|------|---------|---------|---------|
| Enum | TagEnum | RefEnum | MutEnum |
------------------------|------|---------|---------|---------|
Can be generated | | X | X | X |
########################|######|#########|#########|#########|
Is Function | X | X | X | X |
------------------------|------|---------|---------|---------|
Unwrap Function | X | | X | X |
------------------------|------|---------|---------|---------|
UnwrapRef Function | X | | | |
------------------------|------|---------|---------|---------|
UnwrapMut Function | X | | | |
------------------------|------|---------|---------|---------|
ToTag Function | X | | X | X |
------------------------|------|---------|---------|---------|
AsRef Function | X | | | |
------------------------|------|---------|---------|---------|
AsMut Function | X | | | |
------------------------|------|---------|---------|---------|
Get | X | | X | X |
------------------------|------|---------|---------|---------|
GetRef | X | | | |
------------------------|------|---------|---------|---------|
GetMut | X | | | |
------------------------|------|---------|---------|---------|
TagEnum, RefEnum and MutEnums are enums itself which can be generated. The other items are functions which are implemented for the crossed enums. For example:
generates code which looks like:
generate_enum_helpers works with named and unnnamed variant fields. Also it works with variants having no, a single or multiple fields. In case of multiple fields, the unwrap functions return tuples. Further derive and attribute macros are applied to all generated enums except the TagEnum. Please report any issue on GitHub.
To see what code is generated by this proc macro you could use a command like cargo expand
. Fo instance use cargo expand --test named_multifield
to run cargo expand
on a single integration test.