diff options
| author | Stein Somers <git@steinsomers.be> | 2022-01-14 20:28:04 +0100 |
|---|---|---|
| committer | Stein Somers <git@steinsomers.be> | 2022-02-19 00:55:31 +0100 |
| commit | a677e6084049ff4cb2e338d7e33dc034846cdb29 (patch) | |
| tree | f211dc507059180d426f024719e9577a2e753ec7 /library/std/src | |
| parent | feac2ecf1cae1dd0f56bed1cecc6e109c64b3d4f (diff) | |
| download | rust-a677e6084049ff4cb2e338d7e33dc034846cdb29.tar.gz rust-a677e6084049ff4cb2e338d7e33dc034846cdb29.zip | |
Collections: improve the documentation of drain members
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/collections/hash/map.rs | 4 | ||||
| -rw-r--r-- | library/std/src/collections/hash/set.rs | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index 9e61defc31e..c9d91d2c03b 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -547,6 +547,10 @@ impl<K, V, S> HashMap<K, V, S> { /// Clears the map, returning all key-value pairs as an iterator. Keeps the /// allocated memory for reuse. /// + /// If the returned iterator is dropped before being fully consumed, it + /// drops the remaining key-value pairs. The returned iterator keeps a + /// mutable borrow on the vector to optimize its implementation. + /// /// # Examples /// /// ``` diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index d1450987e73..200667ae390 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -227,7 +227,12 @@ impl<T, S> HashSet<T, S> { self.base.is_empty() } - /// Clears the set, returning all elements in an iterator. + /// Clears the set, returning all elements as an iterator. Keeps the + /// allocated memory for reuse. + /// + /// If the returned iterator is dropped before being fully consumed, it + /// drops the remaining elements. The returned iterator keeps a mutable + /// borrow on the vector to optimize its implementation. /// /// # Examples /// |
