Skip to content

Commit a5a655d

Browse files
committed
Merge pull request #1 from cgaebel/drain
Add drain, and link to WIP implementations.
2 parents 994e525 + d54bd9b commit a5a655d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

text/0000-collections-reform-part-2.md

+14
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ pub fn as_slices(&'a self) -> (&'a [T], &'a [T])
108108
This provides some amount of support for viewing the RingBuf like a slice. Unfortunately
109109
the RingBuf may be wrapped, making this impossible. See Alternatives for other designs.
110110

111+
There is an implementation of this at rust-lang/rust#19903.
112+
111113
* For Vec:
112114
```
113115
/// Resizes the `Vec` in-place so that `len()` equals to `new_len`.
@@ -120,6 +122,18 @@ pub fn resize(&mut self, new_len: uint, value: T) where T: Clone
120122
This is actually easy to implement out-of-tree on top of the current Vec API, but it has
121123
been frequently requested.
122124

125+
* For Vec, RingBuf, BinaryHeap, HashMap and HashSet:
126+
```
127+
/// Clears the map, returning all key-value pairs as an iterator. Keeps the
128+
/// allocated memory for reuse.
129+
pub fn drain(&mut self) -> DrainEntries<K, V>;
130+
```
131+
132+
This provides a way to grab elements out of a HashMap by value, without
133+
deallocating the storage for the map itself.
134+
135+
There is a partial implementation of this at rust-lang/rust#19946.
136+
123137
==============
124138
## Deprecate
125139

0 commit comments

Comments
 (0)