diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a968dc..9691d8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ don’t signify). Technically a [breaking-change], but it was something for development only, so I’m not in the slightest bit concerned by it. +- Implement `Default` on `Map` (not just on `RawMap`) + I don’t plan for there to be any real changes from 0.12.1; it should be just a bit of housecleaning and a version bump. diff --git a/src/lib.rs b/src/lib.rs index bcd5c23..de03fb6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -75,6 +75,13 @@ macro_rules! impl_common_methods { self.$field.clear() } } + + impl Default for $t { + #[inline] + fn default() -> $t { + $t::new() + } + } } } @@ -389,6 +396,12 @@ mod tests { test_entry!(test_entry_any, AnyMap); test_entry!(test_entry_cloneany, Map); + #[test] + fn test_default() { + let map: AnyMap = Default::default(); + assert_eq!(map.len(), 0); + } + #[test] fn test_clone() { let mut map: Map = Map::new(); diff --git a/src/raw.rs b/src/raw.rs index 17c3869..07dccf8 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -70,13 +70,6 @@ impl Clone for RawMap where Box: Clone { } } -impl Default for RawMap { - #[inline] - fn default() -> RawMap { - RawMap::new() - } -} - impl_common_methods! { field: RawMap.inner; new() => HashMap::with_hasher(Default::default());