-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Implementation of plan in issue #27787 for btree_range #38610
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
/// println!("{}: {}", key, value); | ||
/// } | ||
/// assert_eq!(Some((&5, &"b")), map.range(Included(&4), Unbounded).next()); | ||
/// assert_eq!(Some((&5, &"b")), map.range((Included(&4), Unbounded)).next()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be shortened to &4..
.
@@ -764,7 +764,7 @@ impl<K: Ord, V> BTreeMap<K, V> { | |||
/// let mut map: BTreeMap<&str, i32> = ["Alice", "Bob", "Carol", "Cheryl"].iter() | |||
/// .map(|&s| (s, 0)) | |||
/// .collect(); | |||
/// for (_, balance) in map.range_mut(Included("B"), Excluded("Cheryl")) { | |||
/// for (_, balance) in map.range_mut::<str, _>((Included("B"), Excluded("Cheryl"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit weird that this would be required now?
The argument can be shortened to "B".."Cheryl"
.
/// println!("{}", elem); | ||
/// } | ||
/// assert_eq!(Some(&5), set.range(Included(&4), Unbounded).next()); | ||
/// assert_eq!(Some(&5), set.range((Included(&4), Unbounded)).next()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&4..
Woo! |
cc @rust-lang/libs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, thanks @djzin!
(Included(start), _) => Included(start), | ||
(Excluded(start), _) => Excluded(start), | ||
(Unbounded, _) => Unbounded, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be self.0
, right? (similarly self.1
below)
/// # } | ||
/// ``` | ||
fn end(&self) -> Option<&T> { | ||
None | ||
fn end(&self) -> Bound<&T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're here could we change these to non-default methods as well? The default of Unbounded
may not make as much sense as None
before.
cc #27787 as github wasn't smart enough. |
Awesome, thanks for taking this on! |
ping @sfackler on the review |
@bors r+ |
📌 Commit bff737d has been approved by |
⌛ Testing commit bff737d with merge 7631057... |
💔 Test failed - status-travis |
@sfackler rebased onto master, fixing up array_vec errors |
@bors: r=sfackler |
📌 Commit bd04c30 has been approved by |
Implementation of plan in issue #27787 for btree_range Still some ergonomics to be worked on, the ::<str,_> is particularly unsightly
☀️ Test successful - status-appveyor, status-travis |
For more info see rust-lang/rust#38610 rust-lang/rust#27787
Still some ergonomics to be worked on, the ::<str,_> is particularly unsightly