-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhancement(derives): extend enum macro to accept any ident and refactor enums #2092
base: dev
Are you sure you want to change the base?
Conversation
btw there is a similar feature https://docs.rs/thiserror/latest/thiserror/. An interesting feature in it is formatting error message with interpolating nested error |
seems cool really, but it still depends on |
@borngraced please resolve conflicts in this PR. |
I tried EnumFromStringify with the new option, like:
I think this may be preferable, because when printing the outer error in the debug format this option prints the nested error in debug as well. How about Question: why the macro is called 'from_stringify' although there is no 'stringify' in the new option? |
BTW the function derive_enum_from_macro in the unsupported case of 'struct' or 'union' always returns ENUM_FROM_INNER_IDENT tag in the error, although derive_enum_from_macro fn could be also called for EnumFromStringify and EnumFromTrait |
Also I think you need to update the doc for EnumFromStringify:
There are identical doc comments |
updated |
#1595
Previously, the EnumFromStringy macro was exclusively utilized to produce the From trait from one enum to another enum only when the inner identifier was "String". However, to enhance this utility, I've expanded the macro's functionality to allow any identifier.
This will eliminates the need for code repetition such as the following while decreasing the codebase to some extent :) :
And just do this instead
So it doesn’t matter if a field inner ident is string or not