-
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
Add append() and split_off() to DList as per coll. reform. #20406
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
This is my first code PR, so I hope I haven't messed it up! |
This should just replace the old |
@@ -263,9 +263,12 @@ impl<T> DList<T> { | |||
}); | |||
} | |||
|
|||
/// Adds all elements from `other` to the end of the list. | |||
/// Destructively adds all elements from `other` to the end of the list. |
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'm not sure destructively is the right word here. "moves" seems more right.
#[stable] | ||
pub fn split_off(&mut self, at: uint) -> DList<T> { | ||
let len = self.len(); | ||
if len <= at { |
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 would make this an assert!(len <= at, "message")
Done first-pass review. |
f15cc5b
to
60d2b72
Compare
@gankro Thanks for the quick review! I fixed all of the issues you've noted. |
60d2b72
to
678b857
Compare
This LGTM, but I like to get a secondary review for most collections code (since it's tricksy). r? @huonw |
678b857
to
8ce6e06
Compare
/// Splits the list into two at the given index. Returns everything after the given index, | ||
/// including the index. | ||
/// | ||
/// This operation should compute in O(n) time. |
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.
Should, or does?
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 just followed the convention of some other doc strings in the file that mention asymptotic performance (e.g., https://github.com/rust-lang/rust/pull/20406/files#diff-4103b030c3b97fcdc52e866d1cb300fbR363). I'm indifferent to the phrasing though, so if you insist, I'll change it to "This operation computes in O(n) time."
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.
fwiw I'm happy to leave it like this, to be handled by a more comprehensive collection doc conventions pass (which I'm sort-of working on).
r=me with fixes |
8ce6e06
to
245b0b5
Compare
245b0b5
to
d0bc031
Compare
@cmr Oops, my bad! I removed the submodule update. |
@cmr does this meet your requirements? |
Yes |
Implements the `append()` and `split_off()` methods proposed by the collections reform part 2 RFC. RFC: rust-lang/rfcs#509 Tracking issue: #19986
Implements the
append()
andsplit_off()
methods proposed by the collections reform part 2 RFC.RFC: rust-lang/rfcs#509
Tracking issue: #19986