Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for sorted collection ranges #27787
Comments
Gankro
added
the
B-unstable
label
Aug 13, 2015
Gankro
changed the title
sorted collection ranges
Tracking issue for sorted collection ranges
Aug 13, 2015
This comment has been minimized.
This comment has been minimized.
|
CC @bluss @apasel422 |
This comment has been minimized.
This comment has been minimized.
|
Will this still allow for efficient implementations of things like just the On Wednesday, August 12, 2015, Alexis Beingessner notifications@github.com
|
This comment has been minimized.
This comment has been minimized.
|
@apasel422 Yes the builder is completely lazy -- |
This comment has been minimized.
This comment has been minimized.
|
I should note the builder API is considerably more hairy internally. Basically requires converting all the static types into dynamic types and then dispatching to the existing impls (for IntoIter) or those proposed in rust-lang/rfcs#1195 |
This comment has been minimized.
This comment has been minimized.
|
Holy shit it actually works: |
This comment has been minimized.
This comment has been minimized.
|
Shoutouts to @zentner-kyle for proposing this API. Big improvement. |
This comment has been minimized.
This comment has been minimized.
|
In practice, with the parent pointer design I anticipate the guts of BTreeMap having the query API just do raw pointers and be an internal impl detail: A range knows how to compute handles from bounds by dispatching to the query API, and then |
This comment has been minimized.
This comment has been minimized.
|
@apasel422 does this sound good to you? |
This comment has been minimized.
This comment has been minimized.
alexcrichton
added
the
T-libs
label
Aug 13, 2015
This comment has been minimized.
This comment has been minimized.
|
I have made an RFC to this affect: rust-lang/rfcs#1254 |
This comment has been minimized.
This comment has been minimized.
|
Removing the |
alexcrichton
added
A-libs
and removed
B-unstable
T-libs
labels
Jan 27, 2016
Gankro
added
the
B-unstable
label
Jan 28, 2016
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
Oh oops there are indeed some unstable APIs tagged with this. |
alexcrichton
added
T-libs
and removed
A-libs
labels
Jan 28, 2016
This comment has been minimized.
This comment has been minimized.
naktinis
commented
Feb 29, 2016
|
What's the state of this? I'm using btree ranges in production code and would be happy to help as much as I can to stabilize this feature. |
This comment has been minimized.
This comment has been minimized.
calebmer
commented
Mar 11, 2016
|
I also would like to know the status as I'm building a program which uses ranges and if there is an idiomatic rust solution I'd love to use that over my own implementation. |
This comment has been minimized.
This comment has been minimized.
|
My understanding is that we're waiting on a new RFC in lieu of rust-lang/rfcs#1254. |
This comment has been minimized.
This comment has been minimized.
naktinis
commented
Apr 13, 2016
|
How can we contribute to the discussion or at least keep track of the remaining issues? |
This comment has been minimized.
This comment has been minimized.
|
@naktinis A pre-RFC or general discussion thread on https://internals.rust-lang.org/ would probably work. |
This comment has been minimized.
This comment has been minimized.
|
cc #33197, a case where the APIs currently segfault apparently |
This comment has been minimized.
This comment has been minimized.
|
It seems to me that the extension |
This comment has been minimized.
This comment has been minimized.
|
@ticki |
bors
added a commit
that referenced
this issue
Jan 14, 2017
bors
added a commit
that referenced
this issue
Jan 15, 2017
This comment has been minimized.
This comment has been minimized.
|
Now that the changes to the surface API have landed, I think we're ready to consider stabilization. @rfcbot rfc merge |
This comment has been minimized.
This comment has been minimized.
|
Grr: @rfcbot fcp merge |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 3, 2017
•
|
Team member @aturon has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
This comment has been minimized.
This comment has been minimized.
|
@aturon, to clarify, what APIs are you thinking of stabilizing as part of this? Just |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton I think we should start with just the method for now, and let the trait bake a while longer. |
This comment has been minimized.
This comment has been minimized.
|
In that case you have my checkmark! |
This comment has been minimized.
This comment has been minimized.
|
There is a small ergonomic issue I came across while writing tests for this relating to taking a range by borrowed key; say you have a map with strings as keys, then it would be nice to just use range syntax to specify the range. Unfortunately this doesn't work, because you would need a #![feature(btree_range)]
#![feature(collections_bound)]
use std::collections::btree_map::BTreeMap;
use std::collections::Bound::*;
fn main() {
let mut map = BTreeMap::new();
map.insert("key".to_string(), "value".to_string());
map.insert("lee".to_string(), "walue".to_string());
map.insert("me".to_string(), "xalue".to_string());
// let range = map.range("key".."me"); // doesn't work
// let range = map.range((Included("key"), Excluded("me"))); // type annotations required
let range = map.range::<str, _>((Included("key"), Excluded("me"))); // finally
for (key, value) in range {
println!("({}, {})", key, value);
}
}I suppose this is covered by not stabilizing |
This comment has been minimized.
This comment has been minimized.
|
@djzin We have to be a bit careful: once the range method is stabilized, we're committing to it working for at least all of the arguments allowed by today's definition of |
This comment has been minimized.
This comment has been minimized.
|
I propose that #33197 should be fixed before stabilization (unfortunately), but it's being fixed. |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 13, 2017
|
|
rfcbot
added
the
final-comment-period
label
Feb 13, 2017
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 13, 2017
|
|
1 similar comment
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 13, 2017
|
|
This comment has been minimized.
This comment has been minimized.
|
The first issue I listed above (not being able to use range syntax) may be fixed at a later time by adding impls such as impl<'a, T: ?Sized> RangeArgument<T> for Range<&'a T> {
fn start(&self) -> Bound<&T> { Included(self.start) }
fn end(&self) -> Bound<&T> { Excluded(self.end) }
}Then one may use For some reason, even though there is only one type that can fit here (as far as I can tell), rust still requires type annotations for the A related problem occurs with None of these issues affect |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Feb 23, 2017
|
The final comment period is now complete. |
frewsxcv
pushed a commit
to frewsxcv/rust
that referenced
this issue
Mar 17, 2017
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Mar 17, 2017
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Mar 17, 2017
bors
closed this
in
37b38a2
Mar 19, 2017
This comment has been minimized.
This comment has been minimized.
|
!?!? REALLY? |
This comment has been minimized.
This comment has been minimized.
|
@Gankro I was shocked too: rust-lang/miri#155 :)
|
This comment has been minimized.
This comment has been minimized.
|
wow
…On Wed, Mar 29, 2017 at 7:35 PM Scott Olson ***@***.***> wrote:
@Gankro <https://github.com/Gankro> I was shocked too: ***@***.***
#diff-b4aea3e418ccdb71239b96952d9cddb6L2
<rust-lang/miri@c6a18ce#diff-b4aea3e418ccdb71239b96952d9cddb6L2>
:)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27787 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAH3yVetV_d9Radh_Efyx_wJP4PucsrDks5rqurGgaJpZM4FqpeG>
.
|
Gankro commentedAug 13, 2015
This covers
btree_rangeandcollections_bound. Both try to address the combinatorics over inclusive/exclusive/none bounds on ordered queries. I am significantly unsatisfied with the current solution, which isbtree.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:This allows you to avoid importing and dispatching on enum. It also has the advantage of making simpler queries simpler. Compare:
This also could potentially address rust-lang/rfcs#1195
And can be extended to support
drainorremovesimilarly;Which if desirable can be sugarred to direct methods on btree in the future.