-
Notifications
You must be signed in to change notification settings - Fork 68
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
Syntax for expressing enums with mixed variants #249
Comments
Try |
Thank you, that works. Is there a way to also allow using it without the value, so that it defaults to |
I think for that you'll need to do a custom implementation of |
Could this be done in addition to the derived |
Sort of - you can create a private mirror of the enum that derives FromMeta and has a conversion into the public enum, and then have your custom impl of FromMeta on the public enum delegate to the derived impl for all cases except the ones that need special handling. I’d be willing to look at a PR or issue for adding |
Would it be possible or desired to add handling of this to the code generated for |
I don't think the way that I think the place that would need work would be here, where we'd want to check if all the fields of the variant were optional and then do something special. However, I'm not sure if that would compose well with newtype variants, and I think any solution we pursue here would need to do that. |
I looked at the way the variant parsing is done from string values, and we could alter the matching a bit for the variants which are |
I'd suggest trying this again, as a bunch of changes in enum variant handling just merged. |
Let's say I have the following:
I can use the variants without type with
#[my_attribute(name = "name", sql_type = "int")]
, but I don't know the correct syntax for specifying the Float or Decimal variants. Could you please point me in the right direction?The text was updated successfully, but these errors were encountered: