Skip to content

Allow enum to implement SpreadAllocate #1042

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

Closed
forgetso opened this issue Nov 24, 2021 · 3 comments
Closed

Allow enum to implement SpreadAllocate #1042

forgetso opened this issue Nov 24, 2021 · 3 comments
Labels
B-feature-request A request for a new feature.

Comments

@forgetso
Copy link
Contributor

Recently, the contract implementation style has changed so that the contract struct derives SpreadAllocate.

This causes a compilation error in contracts that make use of enum with more than one variant. This is because it is not possible to determine a default value, so SpreadAllocate is not defined for enum.

It would be nice if enum was allowed if the Default trait was implemented.

e.g. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=21d9e01c332a660d9e5ab22634250f1a

Here is my hacked version of making this work in ink: prosopo@bdc676d

@HCastano HCastano added the B-feature-request A request for a new feature. label Dec 10, 2021
@ceikit
Copy link

ceikit commented May 15, 2022

@forgetso do you know in current version of Ink if we still need to implement SpreadAllocate for enum?

@xgreenx
Copy link
Collaborator

xgreenx commented May 15, 2022

Yes, you still need to implement SpreadAllocate for all types that are part of the storage(For enums it should be done manually). It will be changed after resolving #1134

@HCastano
Copy link
Contributor

This is not an issue in ink! 4.0 anymore due to #1134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-feature-request A request for a new feature.
Projects
None yet
Development

No branches or pull requests

4 participants