-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for sorted collection ranges #27787
Comments
CC @bluss @apasel422 |
Will this still allow for efficient implementations of things like just the On Wednesday, August 12, 2015, Alexis Beingessner notifications@github.com
|
@apasel422 Yes the builder is completely lazy -- |
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 |
Holy shit it actually works: |
Shoutouts to @zentner-kyle for proposing this API. Big improvement. |
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 |
@apasel422 does this sound good to you? |
I have made an RFC to this affect: rust-lang/rfcs#1254 |
Removing the |
@alexcrichton |
Oh oops there are indeed some unstable APIs tagged with this. |
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. |
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. |
My understanding is that we're waiting on a new RFC in lieu of rust-lang/rfcs#1254. |
How can we contribute to the discussion or at least keep track of the remaining issues? |
@naktinis A pre-RFC or general discussion thread on https://internals.rust-lang.org/ would probably work. |
cc #33197, a case where the APIs currently segfault apparently |
It seems to me that the extension |
@ticki |
Implementation of plan in issue #27787 for btree_range Still some ergonomics to be worked on, the ::<str,_> is particularly unsightly
Now that the changes to the surface API have landed, I think we're ready to consider stabilization. @rfcbot rfc merge |
Grr: @rfcbot fcp merge |
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. |
@aturon, to clarify, what APIs are you thinking of stabilizing as part of this? Just |
@alexcrichton I think we should start with just the method for now, and let the trait bake a while longer. |
In that case you have my checkmark! |
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 |
@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 |
I propose that #33197 should be fixed before stabilization (unfortunately), but it's being fixed. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
1 similar comment
🔔 This is now entering its final comment period, as per the review above. 🔔 |
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 |
The final comment period is now complete. |
!?!? REALLY? |
@gankro I was shocked too: rust-lang/miri#155 :)
|
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>
.
|
For more info see rust-lang/rust#38610 rust-lang/rust#27787
This covers
btree_range
andcollections_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
drain
orremove
similarly;Which if desirable can be sugarred to direct methods on btree in the future.
The text was updated successfully, but these errors were encountered: