Skip to content

Conversation

@mohammadfawaz
Copy link
Contributor

@mohammadfawaz mohammadfawaz commented Mar 23, 2023

Description

Add experimental StorageVec using StorageHandle.

Also introduce index and index_assign to StorageVec and showcase how storage vecs and nested storage vecs could look like with and without the [] operator. These two methods should really be part of traits Index and IndexAssign but we're not ready to implement those yet because we do not have associated types for traits yet.

Note that IndexAssign is inspired by rust-lang/rfcs#1129. This is probably the best we can do given that we don't want references in the language just yet (and probably ever).

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@mohammadfawaz mohammadfawaz self-assigned this Mar 23, 2023
@mohammadfawaz mohammadfawaz added lib: std Standard library testing General testing labels Mar 23, 2023
@mohammadfawaz mohammadfawaz force-pushed the mohammadfawaz/storage_key branch from 100653a to 0fa7196 Compare March 23, 2023 23:00
@mohammadfawaz mohammadfawaz force-pushed the mohammadfawaz/storage_key branch from 26ddeee to 648b2f0 Compare March 24, 2023 14:55
* Added `try_read()` that behaves like `read` but returns an `Option`
* Changed `get` in `StorageMap` to return a `StorageHandle` instead of
  the value directly.
@mohammadfawaz mohammadfawaz force-pushed the mohammadfawaz/storage_key branch from 648b2f0 to be85a10 Compare March 24, 2023 15:36
… nested maps

using both `get/insert` and the `[]` operator
@mohammadfawaz mohammadfawaz force-pushed the mohammadfawaz/new_storage_vec branch 4 times, most recently from 4aff7fc to 9dab5f8 Compare March 25, 2023 01:19
@mohammadfawaz mohammadfawaz changed the title Experimental: StorageVec and new method get_handle to help implementing nested storage vecs Experimental: index, index_assign, and nested storage vecs Mar 25, 2023
@mohammadfawaz mohammadfawaz force-pushed the mohammadfawaz/new_storage_vec branch from 9dab5f8 to e3d49f7 Compare March 25, 2023 01:34
@mohammadfawaz mohammadfawaz changed the base branch from mohammadfawaz/storage_key to mohammadfawaz/nested_maps March 25, 2023 01:34
@mohammadfawaz mohammadfawaz force-pushed the mohammadfawaz/nested_maps branch 2 times, most recently from 7bb31af to 9dfa0fb Compare April 5, 2023 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib: std Standard library testing General testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant