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

Enable the use of [] for StorageMap. #1849

Open
mohammadfawaz opened this issue Jun 4, 2022 · 3 comments
Open

Enable the use of [] for StorageMap. #1849

mohammadfawaz opened this issue Jun 4, 2022 · 3 comments
Labels
compiler: parser Everything to do with the parser enhancement New feature or request language feature Core language features visible to end users P: medium

Comments

@mohammadfawaz
Copy link
Contributor

It would be nice to be able to do this:

storage {
    map: StorageMap<u64, u64>,
}

...

storage.map[key] += value; // destructures to storage.map.insert(key, storage.map.get(key) + value);
@mohammadfawaz mohammadfawaz added enhancement New feature or request language feature Core language features visible to end users P: medium compiler: parser Everything to do with the parser labels Jun 4, 2022
@adlerjohn
Copy link
Contributor

Does this not require enshrining StorageMap into the compiler? Or will this work for anything that implements a storage insertion with a key?

@mohammadfawaz
Copy link
Contributor Author

mohammadfawaz commented Jun 5, 2022

Yeah we may need an Index trait like Rust has think 🤔

@otrho
Copy link
Contributor

otrho commented Jun 6, 2022

#429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: parser Everything to do with the parser enhancement New feature or request language feature Core language features visible to end users P: medium
Projects
Status: Todo
Development

No branches or pull requests

3 participants