-
Notifications
You must be signed in to change notification settings - Fork 428
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
Make Vector usable when initialized with SpreadAllocate
#1070
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This method doesn't panic if there are no values in storage when trying to perform the `get_mut` operation.
This is kinda rendundant since this is already covered by the `spread_allocate_vector_works` test.
Codecov Report
@@ Coverage Diff @@
## master #1070 +/- ##
===========================================
- Coverage 78.75% 62.82% -15.94%
===========================================
Files 248 248
Lines 9371 9371
===========================================
- Hits 7380 5887 -1493
- Misses 1991 3484 +1493
Continue to review full report at Codecov.
|
We got rid of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At the moment the
ink_storage::Vec
type is unusable when initialized usingSpreadAllocate::allocate_spread
. This is becauseVec::len
does not account that thevector can be in a state where the it is initialized but there is nothing in storage.
This creates problems when using
Vec::len
, such as duringDrop
(see here),or
Vec::push
.This PR changes the behaviour of
Vec::len()
to return a0
length if there is nolength in storage. It also changes all uses of
Lazy::get_mut
for modifyingVec.len
touse
Lazy::set
instead since that doesn't panic if no item exists in storage.Currently a draft since there are some other storage data structures which use
Vec
whose tests need to be updated and I'm not quite sure what the best way to fix those
tests is just yet.