-
Notifications
You must be signed in to change notification settings - Fork 35
support for struct-like variants? #5
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
Comments
While the syntax is slightly ambiguous ( |
Yes this is true. You could remove this ambiguity by changing the syntax to something like |
As a preparation I merged the
I now see two options: (SORT [enum $name:ident $(#[$meta:meta])* ]
struct_items [ $( $(#[$imeta:imeta])*
=> $iitem:ident $(( $($ivar:ident : $ityp:ty),* ))*
{ $($ifuncs:tt)* } )* ]
tuple_items [ $( $(#[$imeta:imeta])*
=> $iitem:ident $({ $($ivar:ident : $ityp:ty),* })+
{ $($ifuncs:tt)* } )* ]
// ... (B) (SORT [enum $name:ident $(#[$meta:meta])* ]
items [ $( $(#[$imeta:imeta])*
=> $iitem:ident $(( $($tuple_var:ident : $tuple_typ:ty),* ))*
$({ $($struct_var:ident : $struct_typ:ty),* })*
{ $($ifuncs:tt)* } )* ]
// ... I think (A) is less ambigous - but it has a very verbose signature. How would you approach struct-like-variants? |
Well, both are okay for me. Whichever will actually work :) If both work, I would prefer the one which keeps order of items the same. (I guess the one with struct_items/tuple_items may reorder the enum where tuple and struct items are intermixed). If both are, then I don't care much :) |
Ok, I will try (C) (SORT [$($def:tt)*]
items [ $( $(#[$imeta:meta])*
=> $iitem:ident : $imode:tt $(( $($ivar:ident : $ityp:ty),* ))*
{ $($ifuncs:tt)* } )* ] where |
thx :-) |
This is a great library. 👍
One thing I am missing is struct-like variants:
Support for struct-like variants would be great AND it would help migrating some existing error definitions to quick-error.
I just checked: std-lib uses struct-like variants for some error enums too:
So there seem to be use cases to use both kind of variants. Is it generally possible to implement at all? If so, the syntax could be curly-braces
IoAt{place: ..} {}
instead of round-bracesIoAt(place: ..) {}
.The text was updated successfully, but these errors were encountered: