-
Notifications
You must be signed in to change notification settings - Fork 355
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
Deprecate IntKey
#472
Comments
We cannot currently do this as PrimaryKey has Proposal by @hashedone to use some associated type on the trait, |
If you do this in a backwards-compatible way that doesn't break the current usage of IntKey, then I would be happy to get this in 0.10.1. And we just deprecate the IntKey in 0.11.0 (rather than some warnings popping up in a patch release) |
Taking a stab at this, and I don't think it's possible. As @ethanfrey said, we need a container / wrapper to store the representation of the type, and be able to return a reference to that. If I construct the repr on the fly using Ways around this are:
I would love to be proved wrong, but don't think there's another option here. Even with associated types and The only case that works is for If somehow it could be possible to "cast" or "view" an integer as a (big-endian) slice, then we would be able to return a reference to it. But given that there are two internal representations, sometimes (i.e. in little-endian archs, which are the most common) bytes need to be swapped. And that creates a temporary. Moreover: WebAssembly is (currently) only little-endian (WebAssembly/design#1212). |
My understanding was the idea was a trick to allow sometimes to return If we have to return |
I think @ueco-jb wanted to take a stab at this one, maybe he loves associated types more? |
Sure. I was talking with @hashedone and yes, the alternative would be to have something like a hybrid / variable return type. |
Followed up in #549. |
We can implement
PrimaryKey
over integer types easily using macros.Like in
cw-plus/packages/storage-plus/src/de.rs
Lines 99 to 111 in d536358
and then
cw-plus/packages/storage-plus/src/de.rs
Line 113 in d536358
That means, we can remove the need for
IntKey
, and use the integer values directly. So, better usability, clarity, and user experience in general.The text was updated successfully, but these errors were encountered: