Skip to content

Commit 653400a

Browse files
committed
std: add default implementations to HashMap
1 parent 45c62c0 commit 653400a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libstd/hashmap.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
1919
use clone::Clone;
2020
use cmp::{Eq, Equiv};
21+
use default::Default;
2122
use hash::Hash;
2223
use iter::{Iterator, FromIterator, Extendable};
2324
use iter::{FilterMap, Chain, Repeat, Zip};
@@ -622,6 +623,10 @@ impl<K: Eq + Hash, V> Extendable<(K, V)> for HashMap<K, V> {
622623
}
623624
}
624625

626+
impl<K: Eq + Hash, V> Default for HashMap<K, V> {
627+
fn default() -> HashMap<K, V> { HashMap::new() }
628+
}
629+
625630
/// An implementation of a hash set using the underlying representation of a
626631
/// HashMap where the value is (). As with the `HashMap` type, a `HashSet`
627632
/// requires that the elements implement the `Eq` and `Hash` traits.
@@ -770,6 +775,10 @@ impl<K: Eq + Hash> Extendable<K> for HashSet<K> {
770775
}
771776
}
772777

778+
impl<K: Eq + Hash> Default for HashSet<K> {
779+
fn default() -> HashSet<K> { HashSet::new() }
780+
}
781+
773782
// `Repeat` is used to feed the filter closure an explicit capture
774783
// of a reference to the other set
775784
/// Set operations iterator

0 commit comments

Comments
 (0)