-
Notifications
You must be signed in to change notification settings - Fork 467
Description
Generic Mutable References
Problem
Currently wrappers around objects stored on the contract storage do not provide a way to receive mutable references (&mut T
) to those objects.
Rational
The reason for this is that users could do arbitrary changes to the objects without having an automated way to synchronize the storage.
Example
Storage wrappers like storage::Vec
and storage::HashMap
provide APIs like mutate_with
with which it is possible for users to do an efficient in-place mutation of an object owned by the collection.
Goal
This is the tracking issue to come up with a user friendly, efficient and possibly general way to allow for mutable references that keep their referenced objects in sync between memory and storage.
Solutions
Solution 1: Do not provide mutable reference wrappers
This is the naive approach that we currently use.
However, it has the downside that it simply doesn't support what some users would like to have.