about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2013-09-09 19:28:05 -0700
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2013-09-12 18:54:12 -0700
commit653400a7f0567ed1697ea9181132f7aaca5b2aae (patch)
treeedd316e8f5495b0f69e67c44345774bd9d53718c /src
parent45c62c08f9740dfcdf64c64c8b183acfc22fb3d6 (diff)
downloadrust-653400a7f0567ed1697ea9181132f7aaca5b2aae.tar.gz
rust-653400a7f0567ed1697ea9181132f7aaca5b2aae.zip
std: add default implementations to HashMap
Diffstat (limited to 'src')
-rw-r--r--src/libstd/hashmap.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs
index fab8299f7a7..2b12564281a 100644
--- a/src/libstd/hashmap.rs
+++ b/src/libstd/hashmap.rs
@@ -18,6 +18,7 @@
 use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
 use clone::Clone;
 use cmp::{Eq, Equiv};
+use default::Default;
 use hash::Hash;
 use iter::{Iterator, FromIterator, Extendable};
 use iter::{FilterMap, Chain, Repeat, Zip};
@@ -622,6 +623,10 @@ impl<K: Eq + Hash, V> Extendable<(K, V)> for HashMap<K, V> {
     }
 }
 
+impl<K: Eq + Hash, V> Default for HashMap<K, V> {
+    fn default() -> HashMap<K, V> { HashMap::new() }
+}
+
 /// An implementation of a hash set using the underlying representation of a
 /// HashMap where the value is (). As with the `HashMap` type, a `HashSet`
 /// requires that the elements implement the `Eq` and `Hash` traits.
@@ -770,6 +775,10 @@ impl<K: Eq + Hash> Extendable<K> for HashSet<K> {
     }
 }
 
+impl<K: Eq + Hash> Default for HashSet<K> {
+    fn default() -> HashSet<K> { HashSet::new() }
+}
+
 // `Repeat` is used to feed the filter closure an explicit capture
 // of a reference to the other set
 /// Set operations iterator