-
Notifications
You must be signed in to change notification settings - Fork 28
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
chore: merge BoundedStorable
into Storable
#94
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ielashi
changed the title
chore: Merge
chore: merge Jun 23, 2023
BoundedStorable
into Storable
BoundedStorable
into Storable
dsarlis
reviewed
Jun 23, 2023
I am more in favor of the second approach with the separate
|
What is an example of these issues that you're thinking may arise? |
The community has voted for this solution on the forum. I think this PR is now ready to be reviewed/merged. |
dsarlis
approved these changes
Jul 21, 2023
31 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
We'd like to expand the functionality of
BTreeMap
to support unbounded types. To add this support in a backward-compatible way, theBTreeMap
would need to support both bounded types (i.e. types that implementBoundedStorable
) and unbounded types (i.e. types that don't implementBoundedStorable
).Rust doesn't support generic specializations, so we cannot have the same
BTreeMap
support both use-cases simultaneously. It can either support onlyBoundedStorable
types, or all types implementingStorable
, but without the knowledge of whether aBoundedStorable
implementation is available for those types.Solution
Merge
BoundedStorable
andStorable
into the same trait. The one downside of this approach is that checking whether or not a bound exists now happens at run-time.This impacts the developer experience. Prior to the PR, if you try to store a
String
inside aStableVec
, the compiler will complain thatString
doesn’t implementBoundedStorable
. But, with this solution, it’ll happily compile, and only when you run your code will you see a panic thatString
is not bounded.This PR relates to #84 and #69.