diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index 79e0c2ffea877..0079d92c3cf8a 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -13,6 +13,7 @@ use core::prelude::*; use core::cmp; +use core::default::Default; use core::fmt; use core::iter::{Enumerate, Repeat, Map, Zip}; use core::ops; @@ -697,6 +698,11 @@ pub struct BitvSet { bitv: BigBitv } +impl Default for BitvSet { + #[inline] + fn default() -> BitvSet { BitvSet::new() } +} + impl BitvSet { /// Creates a new bit vector set with initially no contents pub fn new() -> BitvSet { diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index 9d0e8e83698d8..63f3dcde6ca89 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -24,6 +24,7 @@ use core::prelude::*; use alloc::owned::Box; +use core::default::Default; use core::fmt; use core::iter; use core::mem; @@ -262,6 +263,11 @@ impl Deque for DList { } } +impl Default for DList { + #[inline] + fn default() -> DList { DList::new() } +} + impl DList { /// Create an empty DList #[inline] diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index 34d6bbbb66567..07ae675ce58fb 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -14,6 +14,7 @@ use core::prelude::*; +use core::default::Default; use core::mem::{zeroed, replace, swap}; use core::ptr; @@ -36,6 +37,11 @@ impl Mutable for PriorityQueue { fn clear(&mut self) { self.data.truncate(0) } } +impl Default for PriorityQueue { + #[inline] + fn default() -> PriorityQueue { PriorityQueue::new() } +} + impl PriorityQueue { /// An iterator visiting all values in underlying vector, in /// arbitrary order. diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index ce4195789fab6..509ed92caddd7 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -16,6 +16,7 @@ use core::prelude::*; use core::cmp; +use core::default::Default; use core::fmt; use core::iter::RandomAccessIterator; @@ -112,6 +113,11 @@ impl Deque for RingBuf { } } +impl Default for RingBuf { + #[inline] + fn default() -> RingBuf { RingBuf::new() } +} + impl RingBuf { /// Create an empty RingBuf pub fn new() -> RingBuf { diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 45584dd4b28ba..12365ae048b9d 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -17,6 +17,7 @@ use core::prelude::*; +use core::default::Default; use core::fmt; use core::iter::{Enumerate, FilterMap}; use core::mem::replace; @@ -113,6 +114,11 @@ impl MutableMap for SmallIntMap { } } +impl Default for SmallIntMap { + #[inline] + fn default() -> SmallIntMap { SmallIntMap::new() } +} + impl SmallIntMap { /// Create an empty SmallIntMap pub fn new() -> SmallIntMap { SmallIntMap{v: vec!()} } diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index def1c353bc132..9a2c592d99e1b 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -15,6 +15,7 @@ use core::prelude::*; use alloc::owned::Box; +use core::default::Default; use core::fmt; use core::fmt::Show; use core::iter::Peekable; @@ -134,6 +135,11 @@ impl MutableMap for TreeMap { } } +impl Default for TreeMap { + #[inline] + fn default() -> TreeMap { TreeMap::new() } +} + impl TreeMap { /// Create an empty TreeMap pub fn new() -> TreeMap { TreeMap{root: None, length: 0} } @@ -632,6 +638,11 @@ impl MutableSet for TreeSet { fn remove(&mut self, value: &T) -> bool { self.map.remove(value) } } +impl Default for TreeSet { + #[inline] + fn default() -> TreeSet { TreeSet::new() } +} + impl TreeSet { /// Create an empty TreeSet #[inline] diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index c15a6e9e5bf48..3f6577049cd43 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -13,6 +13,7 @@ use core::prelude::*; use alloc::owned::Box; +use core::default::Default; use core::mem::zeroed; use core::mem; use core::uint; @@ -104,6 +105,11 @@ impl MutableMap for TrieMap { } } +impl Default for TrieMap { + #[inline] + fn default() -> TrieMap { TrieMap::new() } +} + impl TrieMap { /// Create an empty TrieMap #[inline] @@ -331,6 +337,11 @@ impl MutableSet for TrieSet { } } +impl Default for TrieSet { + #[inline] + fn default() -> TrieSet { TrieSet::new() } +} + impl TrieSet { /// Create an empty TrieSet #[inline]