Skip to content

Commit

Permalink
Merge pull request #1 from cgaebel/drain
Browse files Browse the repository at this point in the history
Add drain, and link to WIP implementations.
  • Loading branch information
Gankra committed Dec 17, 2014
2 parents 994e525 + d54bd9b commit a5a655d
Showing 1 changed file with 14 additions and 0 deletions.
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>;
```

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

0 comments on commit a5a655d

Please sign in to comment.