From 653400a7f0567ed1697ea9181132f7aaca5b2aae Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 9 Sep 2013 19:28:05 -0700 Subject: std: add default implementations to HashMap --- src/libstd/hashmap.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libstd') 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 Extendable<(K, V)> for HashMap { } } +impl Default for HashMap { + fn default() -> HashMap { 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 Extendable for HashSet { } } +impl Default for HashSet { + fn default() -> HashSet { HashSet::new() } +} + // `Repeat` is used to feed the filter closure an explicit capture // of a reference to the other set /// Set operations iterator -- cgit 1.4.1-3-g733a5