Skip to content
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

Better return values from range/prefix #198

Closed
ethanfrey opened this issue Dec 21, 2020 · 2 comments · Fixed by #432
Closed

Better return values from range/prefix #198

ethanfrey opened this issue Dec 21, 2020 · 2 comments · Fixed by #432
Assignees

Comments

@ethanfrey
Copy link
Member

Builds on #197

When iterating over a range from a Prefix we get from Map, we get back (Vec<u8> , T). However, we know what the Suffix is.Eg for K = (&[u8], U32Key) we could get back (U32Key, T)

@ethanfrey
Copy link
Member Author

When we do implement this, we should:

  1. Add a new trait (ParsableKey ?) with this method, it would not be required for all keys
  2. Add a new method to Map, etc like range_parsed that returns (K, T) not (Vec<u8>, T) but only when K implements ParseableKey.
  3. Implement something like Take storage keys as reference (K -> &K) #265 so we can return an Owned structure from parsing, but pass in a ref to query.

@ethanfrey
Copy link
Member Author

Question: what happens when the primary key is references, eg. &Addr, or &str? It is relatively clear how to do so when the key is owned like eg. String or U32Key. Let's figure out how to define this better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants