-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Continue cleaning up collections::binary_heap
#20133
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @gankro |
/// ``` | ||
#[unstable = "matches collection reform specification, waiting for dust to settle"] | ||
pub fn reserve(&mut self, additional: uint) { | ||
self.data.reserve(additional) | ||
self.data.reserve(additional); |
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 added semicolon (as well as the one from the function just below) results in a compilation error.
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 ran make check
on this and everything passed. What was the error?
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.
Hmm, so full disclosure, I didn't actually compile this myself, but I always get an error such as
error: not all control paths return a value
help: consider removing this semicolon
for situations like this. Though if this is not the case anymore then I stand corrected and I apologize.
Edit: Oops, the return type is ()
😅 My bad, sorry!
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.
Every other method in this module uses a semicolon if the return type is ()
.
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.
Ah yes. You are correct, sorry!
Comments addressed, and rebased on master. |
@@ -184,10 +179,10 @@ impl<T: Ord> BinaryHeap<T> { | |||
/// | |||
/// ``` | |||
/// use std::collections::BinaryHeap; | |||
/// let heap: BinaryHeap<uint> = BinaryHeap::new(); | |||
/// let heap = BinaryHeap::<uint>::new(); |
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 it's pretty rare to put type parameters of paths, and this function is conventionally called as BinaryHeap::new()
rather than BinaryHeap::<T>::new()
. Could this stay as it was before and perhaps have a method call after it to drive inference of what T
is?
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.
(same comment for with_capacity
below)
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.
er, lots of functions below!
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 happy to change this back, but I'm not sure which calls would be appropriate without making the example code redundant for the various methods. Any suggestions? We can also just leave it as
let heap: BinaryHeap<uint> = BinaryHeap::new();
Do any of the guidelines or RFCs contain conventions for example code?
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 don't think we currently have many concrete conventions about examples, but I would expect that examples should be idiomatic code that one would expect to write under normal circumstances. I think a little duplication among examples here is ok, there's already a good bit of duplication by having one on every method, so having a push/pop seems fine.
Awesome, thanks @apasel422! Just a few small nits and otherwise r=me |
Nits addressed. |
Some more tidying up.