-
Notifications
You must be signed in to change notification settings - Fork 13.7k
introduce the Comparable trait for BTree operations #144506
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
base: master
Are you sure you want to change the base?
Conversation
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
r? libs-api because this is related to a future API change, I'm sure if this is the best way to proceed. |
We discussed this in the @rust-lang/libs-api meeting and would be interested in having these traits in the standard library. An idea also came up to also provide blanket implementations of these traits for tuples of types implementing We are however not willing to accept this PR as it is: we want these traits to be public and tracked by a tracking issue so that people can start experimenting with them on nightly. cc @cuviper |
Ok. I can create a tracking issue and update the PR to expose these traits in core with some blanket impls |
This comment has been minimized.
This comment has been minimized.
8ee7f33
to
4dd7d91
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
4dd7d91
to
578b1b4
Compare
This comment has been minimized.
This comment has been minimized.
Doesn't seem to be possible. |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Right, It would probably make a good example though, e.g. some kind of |
Could we make this work by moving the reference to |
Tracking issue: #145986
This introduces the Equivalent and Comparable traits into core, under the
comparable_trait
feature flag. This exposesComparable
for btree key lookups, with a blanket impl forBorrow
keys to remain backwards compatible.The one annoying thing is that we still need
Q: Ord
in order to provide the panic messages for bad usage in range queries. One could likely address this but it would move the branch inside the search loop which might impact performance. Another approach is to move the condition out, but that won't help if we want the same helpful panic condition in any potential exposed API. Note that this check is not needed for memory safety (as we already have to deal with invalid Ord impls) so maybe such a check is not really that necessary. The alternative is we accept thisQ: Ord
bound as not a significant limitation.