Skip to content
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

Enum spread allocate #1080

Closed
wants to merge 7 commits into from
Closed

Conversation

forgetso
Copy link
Contributor

@forgetso forgetso commented Dec 13, 2021

This is my attempt to identify when an enum has derived Default from its representation as a synstructure for #1042.

For exmaple, an enum like this would be allowed:

#[derive(Default)]
enum Enum { A, B, #[default] C }

But this one would fail:
enum Enum { A, B, C }

I don't know how to do this without using the Default derive. If you create the default value using impl, the synstructure, contains no information about the default. Additionally, you cannot pass impl into the synstructure::Structure::new.

    pub enum Enum {
        A,
        B,
        C,
    }

    impl Default for Status {
        fn default() -> Self { Enum::C }
    }

@forgetso
Copy link
Contributor Author

Also, I've been running rustfmt on this but it seems to format it differently from your CI rustfmt.

@HCastano
Copy link
Contributor

@forgetso thanks for the PR! I'm gonna put this on-ice since we're still unsure about the direction we want to take with SpreadAllocate in general.

@HCastano HCastano added the E-on-ice The issue or PR is currently on ice and not further discussed or developed. label Dec 14, 2021
@paritytech-cicd-pr
Copy link

🦑 📈 ink! Example Contracts ‒ Changes Report 📉 🦑

These are the results when building the examples/* contracts from this branch with cargo-contract 0.17.0-86510f8 and comparing them to ink! master:

Δ Optimized Size Δ Used Gas Total Optimized Size Total Used Gas
accumulator 1.44 K
adder 2.94 K
contract-terminate +14_926 1.31 K 215_704
contract-transfer +14_305 7.98 K 15_704
delegator +41_047 7.63 K 51_343
dns +31_959 10.20 K 47_112
erc1155 +46_413 27.50 K 94_224
erc20 +37_098 9.80 K 47_112
erc721 +90_930 13.70 K 125_632
flipper +15_357 1.76 K 15_704
incrementer +15_364 1.64 K 15_704
multisig +46_824 26.79 K 103_580
proxy +29_614 3.81 K 32_243
rand-extension +9_050 5.12 K 15_704
subber 2.96 K
trait-erc20 +36_453 10.10 K 47_112
trait-flipper +15_362 1.53 K 15_704
trait-incrementer +30_728 1.62 K 31_408

Link to the run | Last update: Tue Feb 8 21:14:16 CET 2022

@HCastano
Copy link
Contributor

Closing since this will be made obsolete with #1217. Thanks for the PR though!

@HCastano HCastano closed this May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-on-ice The issue or PR is currently on ice and not further discussed or developed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants