Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collections: Add missing Default impls #14769

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/libcollections/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use core::prelude::*;

use alloc::owned::Box;
use core::default::Default;
use core::fmt;
use core::iter;
use core::mem;
Expand Down Expand Up @@ -262,6 +263,11 @@ impl<T> Deque<T> for DList<T> {
}
}

impl<T> Default for DList<T> {
#[inline]
fn default() -> DList<T> { DList::new() }
}

impl<T> DList<T> {
/// Create an empty DList
#[inline]
Expand Down
6 changes: 6 additions & 0 deletions src/libcollections/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use core::prelude::*;

use core::default::Default;
use core::mem::{zeroed, replace, swap};
use core::ptr;

Expand All @@ -36,6 +37,11 @@ impl<T: Ord> Mutable for PriorityQueue<T> {
fn clear(&mut self) { self.data.truncate(0) }
}

impl<T: Ord> Default for PriorityQueue<T> {
#[inline]
fn default() -> PriorityQueue<T> { PriorityQueue::new() }
}

impl<T: Ord> PriorityQueue<T> {
/// An iterator visiting all values in underlying vector, in
/// arbitrary order.
Expand Down
6 changes: 6 additions & 0 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use core::prelude::*;

use core::cmp;
use core::default::Default;
use core::fmt;
use core::iter::RandomAccessIterator;

Expand Down Expand Up @@ -112,6 +113,11 @@ impl<T> Deque<T> for RingBuf<T> {
}
}

impl<T> Default for RingBuf<T> {
#[inline]
fn default() -> RingBuf<T> { RingBuf::new() }
}

impl<T> RingBuf<T> {
/// Create an empty RingBuf
pub fn new() -> RingBuf<T> {
Expand Down
6 changes: 6 additions & 0 deletions src/libcollections/smallintmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use core::prelude::*;

use core::default::Default;
use core::fmt;
use core::iter::{Enumerate, FilterMap};
use core::mem::replace;
Expand Down Expand Up @@ -113,6 +114,11 @@ impl<V> MutableMap<uint, V> for SmallIntMap<V> {
}
}

impl<V> Default for SmallIntMap<V> {
#[inline]
fn default() -> SmallIntMap<V> { SmallIntMap::new() }
}

impl<V> SmallIntMap<V> {
/// Create an empty SmallIntMap
pub fn new() -> SmallIntMap<V> { SmallIntMap{v: vec!()} }
Expand Down
11 changes: 11 additions & 0 deletions src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -134,6 +135,11 @@ impl<K: Ord, V> MutableMap<K, V> for TreeMap<K, V> {
}
}

impl<K: Ord, V> Default for TreeMap<K,V> {
#[inline]
fn default() -> TreeMap<K, V> { TreeMap::new() }
}

impl<K: Ord, V> TreeMap<K, V> {
/// Create an empty TreeMap
pub fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
Expand Down Expand Up @@ -632,6 +638,11 @@ impl<T: Ord> MutableSet<T> for TreeSet<T> {
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
}

impl<T: Ord> Default for TreeSet<T> {
#[inline]
fn default() -> TreeSet<T> { TreeSet::new() }
}

impl<T: Ord> TreeSet<T> {
/// Create an empty TreeSet
#[inline]
Expand Down
11 changes: 11 additions & 0 deletions src/libcollections/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -104,6 +105,11 @@ impl<T> MutableMap<uint, T> for TrieMap<T> {
}
}

impl<T> Default for TrieMap<T> {
#[inline]
fn default() -> TrieMap<T> { TrieMap::new() }
}

impl<T> TrieMap<T> {
/// Create an empty TrieMap
#[inline]
Expand Down Expand Up @@ -331,6 +337,11 @@ impl MutableSet<uint> for TrieSet {
}
}

impl Default for TrieSet {
#[inline]
fn default() -> TrieSet { TrieSet::new() }
}

impl TrieSet {
/// Create an empty TrieSet
#[inline]
Expand Down