Skip to content

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

Merged
merged 1 commit into from
Dec 27, 2014
Merged

Continue cleaning up collections::binary_heap #20133

merged 1 commit into from
Dec 27, 2014

Conversation

apasel422
Copy link
Contributor

Some more tidying up.

@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

r? @gankro

@alexcrichton alexcrichton assigned Gankra and unassigned alexcrichton Dec 22, 2014
/// ```
#[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);
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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!

Copy link
Contributor Author

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 ().

Copy link
Contributor

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!

@apasel422
Copy link
Contributor Author

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();
Copy link
Member

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?

Copy link
Member

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)

Copy link
Member

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!

Copy link
Contributor Author

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?

Copy link
Member

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.

@alexcrichton
Copy link
Member

Awesome, thanks @apasel422! Just a few small nits and otherwise r=me

@apasel422
Copy link
Contributor Author

Nits addressed.

bors added a commit that referenced this pull request Dec 26, 2014
@bors bors merged commit fe9f1be into rust-lang:master Dec 27, 2014
@apasel422 apasel422 deleted the binary_heap branch January 1, 2015 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants