From f7e974e4322b53cdadddf2ca8c72eaf419d406f2 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Fri, 15 Sep 2017 13:32:45 -0400 Subject: [PATCH] HashMap::new and HashSet::new do not allocate --- src/libstd/collections/hash/map.rs | 3 +++ src/libstd/collections/hash/set.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index fbb69ca974930..96af227257824 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -588,6 +588,9 @@ impl HashMap impl HashMap { /// 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 9771363d545cd..51698ce7c17ca 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -125,6 +125,9 @@ pub struct HashSet { impl HashSet { /// 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 /// /// ```