-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.
Description
This covers btree_range
and collections_bound
. Both try to address the combinatorics over inclusive/exclusive/none bounds on ordered queries. I am significantly unsatisfied with the current solution, which is btree.range(Bound(&K), Bound(&K))
. This pushes all the combinatorics into a nasty calling convention. Instead, I believe we would be better served by a build pattern:
for x in btree.range().ge(&min).lt(&max) { .. }
This allows you to avoid importing and dispatching on enum. It also has the advantage of making simpler queries simpler. Compare:
// today (assuming you've totally imported the bound variants)
for x in btree.range(Unbounded, Inclusive(&max)) {
// tomorrow?
for x in btree.range().le(&max) { .. }
This also could potentially address rust-lang/rfcs#1195
let pred = btree.range().le(&max).get();
And can be extended to support drain
or remove
similarly;
for x in btree.range_mut().gt(&min).drain() { .. }
ler pred = btree.range_mut().le(&max).remove();
Which if desirable can be sugarred to direct methods on btree in the future.
calebmer, taocp, Kerollmops, mpartel, pingiun and 6 more
Metadata
Metadata
Assignees
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.