diff options
| author | Jon Gjengset <jon@thesquareplanet.com> | 2017-09-15 13:32:45 -0400 |
|---|---|---|
| committer | Jon Gjengset <jon@thesquareplanet.com> | 2017-09-15 13:32:56 -0400 |
| commit | f7e974e4322b53cdadddf2ca8c72eaf419d406f2 (patch) | |
| tree | d871e16676ef627c582368e167cddaa722d24120 /src/libstd | |
| parent | fd4bef54abafe6d93ec3c87498de696da6ef5819 (diff) | |
| download | rust-f7e974e4322b53cdadddf2ca8c72eaf419d406f2.tar.gz rust-f7e974e4322b53cdadddf2ca8c72eaf419d406f2.zip | |
HashMap::new and HashSet::new do not allocate
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 3 | ||||
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index fbb69ca9749..96af2272578 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -588,6 +588,9 @@ impl<K, V, S> HashMap<K, V, S> impl<K: Hash + Eq, V> HashMap<K, V, RandomState> { /// Creates an empty `HashMap`. /// + /// The hash map is initially created with a capacity of 0, so it will not allocate until it + /// is first inserted into. + /// /// # Examples /// /// ``` diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 9771363d545..51698ce7c17 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -125,6 +125,9 @@ pub struct HashSet<T, S = RandomState> { impl<T: Hash + Eq> HashSet<T, RandomState> { /// Creates an empty `HashSet`. /// + /// The hash set is initially created with a capacity of 0, so it will not allocate until it + /// is first inserted into. + /// /// # Examples /// /// ``` |
