about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-07-25 03:07:44 -0700
committerbors <bors@rust-lang.org>2013-07-25 03:07:44 -0700
commit906264b50fa6b69eed567388063233bd279242b1 (patch)
treecfe2808a6e0bbb5aec20ade1ee0af8174f8fc34d /src/libstd
parentb30a16c9aefbc568f67c8121f170b6d478102c5f (diff)
parentf37c7cd30651e6514c6ac03a081940e28a53292c (diff)
downloadrust-906264b50fa6b69eed567388063233bd279242b1.tar.gz
rust-906264b50fa6b69eed567388063233bd279242b1.zip
auto merge of #8015 : msullivan/rust/default-methods, r=nikomatsakis
Lots of changes to vtable resolution, handling of super/self method calls in default methods. Fix a lot of trait inheritance bugs.

r? @nikomatsakis 
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/cmp.rs6
-rw-r--r--src/libstd/iterator.rs19
2 files changed, 24 insertions, 1 deletions
diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs
index 8a13cab28c3..eee786524f5 100644
--- a/src/libstd/cmp.rs
+++ b/src/libstd/cmp.rs
@@ -86,6 +86,12 @@ pub trait TotalOrd: TotalEq {
     fn cmp(&self, other: &Self) -> Ordering;
 }
 
+impl TotalEq for Ordering {
+    #[inline]
+    fn equals(&self, other: &Ordering) -> bool {
+        *self == *other
+    }
+}
 impl TotalOrd for Ordering {
     #[inline]
     fn cmp(&self, other: &Ordering) -> Ordering {
diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs
index 0c2a7bb7b40..5ea7585a3df 100644
--- a/src/libstd/iterator.rs
+++ b/src/libstd/iterator.rs
@@ -96,7 +96,7 @@ impl<A, T: DoubleEndedIterator<A>> Iterator<A> for InvertIterator<A, T> {
     fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
 }
 
-impl<A, T: Iterator<A>> DoubleEndedIterator<A> for InvertIterator<A, T> {
+impl<A, T: DoubleEndedIterator<A>> DoubleEndedIterator<A> for InvertIterator<A, T> {
     #[inline]
     fn next_back(&mut self) -> Option<A> { self.iter.next() }
 }
@@ -343,6 +343,18 @@ pub trait IteratorUtil<A> {
     /// ~~~
     fn collect<B: FromIterator<A, Self>>(&mut self) -> B;
 
+    /// Loops through the entire iterator, collecting all of the elements into
+    /// a unique vector. This is simply collect() specialized for vectors.
+    ///
+    /// # Example
+    ///
+    /// ~~~ {.rust}
+    /// let a = [1, 2, 3, 4, 5];
+    /// let b: ~[int] = a.iter().transform(|&x| x).to_owned_vec();
+    /// assert!(a == b);
+    /// ~~~
+    fn to_owned_vec(&mut self) -> ~[A];
+
     /// Loops through `n` iterations, returning the `n`th element of the
     /// iterator.
     ///
@@ -539,6 +551,11 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
         FromIterator::from_iterator(self)
     }
 
+    #[inline]
+    fn to_owned_vec(&mut self) -> ~[A] {
+        self.collect()
+    }
+
     /// Return the `n`th item yielded by an iterator.
     #[inline]
     fn nth(&mut self, mut n: uint) -> Option<A> {