Skip to content

Commit

Permalink
HashMap::new and HashSet::new do not allocate
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhoo committed Sep 15, 2017
1 parent fd4bef5 commit f7e974e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
/// ```
Expand Down
3 changes: 3 additions & 0 deletions src/libstd/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
/// ```
Expand Down

0 comments on commit f7e974e

Please sign in to comment.