-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add new()
function to StorageKey
#5096
Conversation
new()
function to StorageKeynew()
function to StorageKey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused about your comments in the issue regarding the usage of a String
and a StorageString
. The type in the map is StorageString
but you create a string that gets assigned to some arbitrary key and then via magic it becomes the StorageString
type.
I've not looking into handling StorageKey
s so there's probably something going on there.
Description
When creating complex storage types, storing of a
StorageKey
is sometimes needed. In these cases anew()
function is appropriate.For example, when we have the following storage block:
In order to store a
StorageString
in aStorageMap
, theStorageKey<StorageString>
annotation is needed.From there, we can store a
String
by creating aStorageKey
, storing aString
at said key, and then storing theStorageKey
in theStorageMap
:The introduction of
new()
would change this to the following:Checklist
Breaking*
orNew Feature
labels where relevant.