Skip to content
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 drain, and link to WIP implementations. #1

Merged
merged 2 commits into from
Dec 17, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions text/0000-collections-reform-part-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ pub fn as_slices(&'a self) -> (&'a [T], &'a [T])
This provides some amount of support for viewing the RingBuf like a slice. Unfortunately
the RingBuf may be wrapped, making this impossible. See Alternatives for other designs.

There is an implementation of this at rust-lang/rust#19903.

* For Vec:
```
/// Resizes the `Vec` in-place so that `len()` equals to `new_len`.
Expand All @@ -120,6 +122,18 @@ pub fn resize(&mut self, new_len: uint, value: T) where T: Clone
This is actually easy to implement out-of-tree on top of the current Vec API, but it has
been frequently requested.

* For Vec, RingBuf, BinaryHeap, HashMap and HashSet:
```
/// Clears the map, returning all key-value pairs as an iterator. Keeps the
/// allocated memory for reuse.
pub fn drain(&mut self) -> DrainEntries<K, V>;
Copy link
Owner

Choose a reason for hiding this comment

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

Close enough for horse grenades! Ship it!

```

This provides a way to grab elements out of a HashMap by value, without
deallocating the storage for the map itself.

There is a partial implementation of this at rust-lang/rust#19946.

==============
## Deprecate

Expand Down