feat: add mutable methods to the storage `Vec` type
Feature Request
Describe the Feature Request
The Vec type is for now an append-only data structure. We can only append at the end, and retrieve existing values.
We could also add:
setdelete/unset(reset value at index i to default value)pop
I can help if needed.
Proposal: also improve the API so that one can do
self.storage_vec.at(i) instead of self.storage_vec.at(i).read()
self.storage_vec.append(x) instead of self.storage_vec.append().write(x)
this is a breaking change - additionally - it merges the concepts of finding a Vec cell, and the actual edit of one, which makes it much less explicit.
append is quite misleading in this case, it's connoted as mutating a data structure.
Perhaps something like this would be better:
self.storage_vec.last_mut()-> returns the storage path to the last storage cell of the vec, so that we can do
self.storage_vec.last_mut().write(x) (or self.storage_vec.last_mut().read()).
And thus, the features I would like to see could be expressed as
self.storage_vec.get_mut(i).write(x) self.storage_vec.get_mut(i).delete()