Skip to content

Conversation

@cgaebel
Copy link
Contributor

@cgaebel cgaebel commented Dec 17, 2014

It is useful to move all the elements out of a hashmap without deallocating
the underlying buffer. It came up in IRC, and this patch implements it as
drain.

r? @gankro
cc: @frankmcsherry

@alexcrichton
Copy link
Member

Let's please hold off merging this until rust-lang/rfcs#509 is merged as well (but review is fine!)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: debug_assert_eq!

@reem
Copy link
Contributor

reem commented Dec 17, 2014

cc @aturon this is what we discussed on IRC yesterday.

@cgaebel
Copy link
Contributor Author

cgaebel commented Dec 18, 2014

cc @thestinger for Vec changes.

RingBuf/Vec .drain has been added if y'all want to review that too!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

@cgaebel
Copy link
Contributor Author

cgaebel commented Dec 18, 2014

BinaryHeap is done now, too. Not sure who "owns" that (and ringbuf too, for that matter), but someone should cc them.

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 don't think this deprecation is in the RFC. It should probably be added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if this is strictly desirable. MoveItems in theory lets you move the collection to somewhere else by passing around an iterator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's why I'm thinking it should be added to the RFC so people can debate it.

@Gankra
Copy link
Contributor

Gankra commented Dec 18, 2014

RingBuf is primarily authored by @csherratt. BinaryHeap hasn't really had any heavy work done on it in a while. Pretty simple collection relatively speaking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/BinarHeap/BinaryHeap

@Gankra
Copy link
Contributor

Gankra commented Dec 18, 2014

I take it back, @apasel422 is in charge of BinaryHeap forever now.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ///

@cgaebel
Copy link
Contributor Author

cgaebel commented Dec 18, 2014

This has been rebased, and I believe all review comments have been addressed.

r? @gankro

@ghost
Copy link

ghost commented Dec 18, 2014

The changes to ringbuf LGTM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Word on high from lord @aturon is that these should be called Drain (as Iterators should be named after their creation method -- Iter, IterMut, IntoIter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All hail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awkward sentence. Either have a period after iterator, or just have "... iterator that clears the..."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Examples

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other docs in this file say "Example", but in other files it says "Examples" even when there's only one test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New convention is examples per the rule of @steveklabnik; anything else is out of date.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even when the english language disagrees? afaik singular forms of nouns should be used when there's only one.

@Gankra
Copy link
Contributor

Gankra commented Dec 19, 2014

Ok, done my full pass.

@cgaebel
Copy link
Contributor Author

cgaebel commented Dec 19, 2014

Moi aussi.

@Gankra
Copy link
Contributor

Gankra commented Dec 19, 2014

r=me with fixed doc + squash

…aring.

It is useful to move all the elements out of some collections without
deallocating the underlying buffer. It came up in IRC, and this patch
implements it as `drain`. This has been discussed as part of RFC 509.

r? @gankro
cc: @frankmcsherry
@cgaebel
Copy link
Contributor Author

cgaebel commented Dec 19, 2014

bors added a commit that referenced this pull request Dec 21, 2014
It is useful to move all the elements out of a hashmap without deallocating
the underlying buffer. It came up in IRC, and this patch implements it as
`drain`.

r? @gankro
cc: @frankmcsherry
@bors bors merged commit d57f259 into rust-lang:master Dec 21, 2014
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.

10 participants