-
Couldn't load subscription status.
- Fork 13.9k
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.