-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support for streamlined nested-enum declarations? #5
Comments
Hm this is an interesting idea! I will definitely consider implementing it as long as it doesn't degrade other features. I'll look into it over the coming days |
What about something like: nest! {
enum Foo {
_(struct Bar(usize)),
_(enum Baz { Quz }),
}
} I see multiple possible behaviors if normal or nested types are allowed:
|
I appreciate the idea behind the macro, but I'm concerned it might complicate comprehension for those not already familiar with it. Nestify allows for defining structures in place of types. I believe using explicit syntax, as shown in the original proposal by @daniel5151, is clearer and immediately understandable since It eliminates ambiguity about the structure's design. However, I'm not fully convinced that deviating from whats more inline official rust syntax is a would be beneficial. Its for sure a balance between being immediately understandable and easy to write.
|
First off - awesome crate!
As someone who often works with deeply nested C structures and JSON specs, this will come quite in handy in many different places :)
I wanted to float a feature request by you that I think might be a natural extension to nestify.
Consider this example:
While this works, it does require the author to repeat the enum variant names twice (once as part of the variant, and once again as part of the struct), which is somewhat unfortunate.
Would it be possible to have the
nest!
macro accept a shorthand for this pattern instead? e.g:...precise syntax subject to bikeshedding / tweaks, of course.
Maybe requiring a sigil on the outer
enum Foo
to opt-in to this infer syntax?Maybe having a way to add a prefix / postfix to the generated struct name?
Do you think is is something nestify could support?
The text was updated successfully, but these errors were encountered: