-
Notifications
You must be signed in to change notification settings - Fork 10
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
Enhanced enum support and types #55
Comments
just for reference, could you add what |
Oh, good idea! Here's the current output:
The current "problems" with this are:
|
Also, perhaps rather than changing the default behavior, this should just be another supported option? Because this would be a breaking change, in that enums would be converted in a different way. Basically, instead of inlining the variant data, it would wrap it in a |
Can you try using #[serde(flatten)], maybe that gives you something closer to what you're looking for.. Make sure you're using the latest version |
See 2141be7 |
@AnthonyMichaelTDM What exactly am I supposed to be annotating with Cargo.toml:
Input:
Output:
|
huh... that's odd |
Yeah, this just isn't implemented (see our tests for enum). Here's the relevant section in the code: I pushed a fix that should help with the other cases though. Regarding usage in the frontend though, I completely agree. If you don't have time to implement the above ^, you can try changing tuple enums to a struct enum with a field:
(I see your points about this here though) That should hopefully get you a bit closer to what you want to achieve. Otherwise, I would love a PR! I think the original author (huge thanks to @AravindPrabhs 🙌 ) didn't need this case. |
Hello again!
In my project, I use a lot of enums, and it is often desirable to match on the variants.
As a result, it'd be nice if something like this:
Converted to something like this:
My reasoning:
It provides the frontend code with everything it needs. Many functions may only be interested in the case for the banana, and can take just that as a parameter. It makes it so that none of the frontend types are anonymous anymore. It also provides an enum of all the variants as well, since that is often useful. And it allows for a full conversion of the ADT pattern, such that you can narrow the types in the frontend code. For example:
Thoughts?
The text was updated successfully, but these errors were encountered: