-
Notifications
You must be signed in to change notification settings - Fork 119
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
Handling of enum with sub-variants #278
Comments
Yep, this is a limitation. The changes that we need to make this work involve modifying the macro code to recursively walk the enums. I'm very much in favor of this change: if you or any other reader wants to tackle this I'd be happy to review and merge a PR. Otherwise, I'll likely get to this myself Eventually. For now, you could work around it by manually implementing the Actionlike trait. |
I began trying to write something that would work for my case as a first step (quite new to Rust tbh), but I stumbled upon something that may cause problem: the whole point of the Actionlike is to match an enum variant with an unique usize, right? How would it be translated for this enum? enum Foo {
Foo1,
Other(usize)
} We would need One thing I can think of would be to change the identifier used to match enum-variants but that would be a lot of changes (and I do not even know if it would work in all cases). |
Random question that I'm sure is massively oversimplifying the problem, but doesn't enum_map tackle fundamentally the same issue? Particularly the If nothing else, shows it's possible to enumerate all available enum values, given some reasonable constraints that would apply equally well to input mappings (e.g. not having more than I just ran into the same issue trying to do the Is there an example of manually implementing |
Yep, that should tackle the issue. I'm going to play around with refactoring |
Hi,
I am not sure if this is a bug/limitation of the current implementation but I encounter some issues with the Actionlike macro being used with "complex" enums: it seems to construct them by default, thus loosing the information.
First I was "forced" to add the Default trait to my
ActionBars
enum, but when running, it seems that everytime anActionBar
or theTest
variant of the enum was triggered, it was reset to default when passed to theActionState
.Code that spawns the bundle
Actually reading the action:
And in the case of subtypes, it always prints either
ActionBars(AB0)
orTest(0)
, even when it should have printedActionBars(AB1)
orTest(42)
.Is this a limitation or did I miss something to make this work?
If it is a limitation, I would like to have this as an enhancement if possible.
Thank you
The text was updated successfully, but these errors were encountered: