Skip to content

Commit f7e974e

Browse files
committed
HashMap::new and HashSet::new do not allocate
1 parent fd4bef5 commit f7e974e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/libstd/collections/hash/map.rs

+3
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,9 @@ impl<K, V, S> HashMap<K, V, S>
588588
impl<K: Hash + Eq, V> HashMap<K, V, RandomState> {
589589
/// Creates an empty `HashMap`.
590590
///
591+
/// The hash map is initially created with a capacity of 0, so it will not allocate until it
592+
/// is first inserted into.
593+
///
591594
/// # Examples
592595
///
593596
/// ```

src/libstd/collections/hash/set.rs

+3
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ pub struct HashSet<T, S = RandomState> {
125125
impl<T: Hash + Eq> HashSet<T, RandomState> {
126126
/// Creates an empty `HashSet`.
127127
///
128+
/// The hash set is initially created with a capacity of 0, so it will not allocate until it
129+
/// is first inserted into.
130+
///
128131
/// # Examples
129132
///
130133
/// ```

0 commit comments

Comments
 (0)