about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-04-30 15:46:47 -0700
committerbors <bors@rust-lang.org>2014-04-30 15:46:47 -0700
commit9f484e616e8731c3fd9346460a71156ddba454b4 (patch)
tree040aacc920be7044251435cb3883e4f7a1166aa6 /src/libstd
parent3aadbed612fd877488b11347d83bfd8f6dc08fe6 (diff)
parent03609e5a5e8bdca9452327d44e25407ce888d0bb (diff)
downloadrust-9f484e616e8731c3fd9346460a71156ddba454b4.tar.gz
rust-9f484e616e8731c3fd9346460a71156ddba454b4.zip
auto merge of #13648 : gereeter/rust/removed-rev, r=alexcrichton
In the process, `Splits` got changed to be more like `CharSplits` in `str` to present the DEI interface.

Note that `treemap` still has a `rev_iter` function because it seems like it would be a significant interface change to expose a DEI - the iterator would have to gain an extra pointer, the completion checks would be more complicated, and it isn't easy to check that such an implementation is correct due to the use of unsafety to subvert the aliasing properties of `&mut`.

This fixes #9391.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/path/posix.rs45
-rw-r--r--src/libstd/path/windows.rs34
-rw-r--r--src/libstd/slice.rs154
-rw-r--r--src/libstd/str.rs84
4 files changed, 155 insertions, 162 deletions
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index 4affea37e35..d69e9b448be 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -1,4 +1,4 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -16,11 +16,11 @@ use clone::Clone;
 use cmp::{Eq, TotalEq};
 use from_str::FromStr;
 use io::Writer;
-use iter::{AdditiveIterator, Extendable, Iterator, Map};
+use iter::{DoubleEndedIterator, Rev, AdditiveIterator, Extendable, Iterator, Map};
 use option::{Option, None, Some};
 use str;
 use str::Str;
-use slice::{CloneableVector, RevSplits, Splits, Vector, VectorVector,
+use slice::{CloneableVector, Splits, Vector, VectorVector,
             ImmutableEqVector, OwnedVector, ImmutableVector};
 use vec::Vec;
 
@@ -29,14 +29,15 @@ use super::{BytesContainer, GenericPath, GenericPathUnsafe};
 /// Iterator that yields successive components of a Path as &[u8]
 pub type Components<'a> = Splits<'a, u8>;
 /// Iterator that yields components of a Path in reverse as &[u8]
-pub type RevComponents<'a> = RevSplits<'a, u8>;
+#[deprecated = "replaced by Rev<Components<'a>>"]
+pub type RevComponents<'a> = Rev<Components<'a>>;
 
 /// Iterator that yields successive components of a Path as Option<&str>
 pub type StrComponents<'a> = Map<'a, &'a [u8], Option<&'a str>,
                                        Components<'a>>;
 /// Iterator that yields components of a Path in reverse as Option<&str>
-pub type RevStrComponents<'a> = Map<'a, &'a [u8], Option<&'a str>,
-                                          RevComponents<'a>>;
+#[deprecated = "replaced by Rev<StrComponents<'a>>"]
+pub type RevStrComponents<'a> = Rev<StrComponents<'a>>;
 
 /// Represents a POSIX file path
 #[deriving(Clone)]
@@ -308,8 +309,8 @@ impl GenericPath for Path {
 
     fn ends_with_path(&self, child: &Path) -> bool {
         if !child.is_relative() { return false; }
-        let mut selfit = self.rev_components();
-        let mut childit = child.rev_components();
+        let mut selfit = self.components().rev();
+        let mut childit = child.components().rev();
         loop {
             match (selfit.next(), childit.next()) {
                 (Some(a), Some(b)) => if a != b { return false; },
@@ -396,16 +397,9 @@ impl Path {
 
     /// Returns an iterator that yields each component of the path in reverse.
     /// See components() for details.
-    pub fn rev_components<'a>(&'a self) -> RevComponents<'a> {
-        let v = if *self.repr.get(0) == SEP_BYTE {
-            self.repr.slice_from(1)
-        } else { self.repr.as_slice() };
-        let mut ret = v.rsplit(is_sep_byte);
-        if v.is_empty() {
-            // consume the empty "" component
-            ret.next();
-        }
-        ret
+    #[deprecated = "replaced by .components().rev()"]
+    pub fn rev_components<'a>(&'a self) -> Rev<Components<'a>> {
+        self.components().rev()
     }
 
     /// Returns an iterator that yields each component of the path as Option<&str>.
@@ -416,8 +410,9 @@ impl Path {
 
     /// Returns an iterator that yields each component of the path in reverse as Option<&str>.
     /// See components() for details.
-    pub fn rev_str_components<'a>(&'a self) -> RevStrComponents<'a> {
-        self.rev_components().map(str::from_utf8)
+    #[deprecated = "replaced by .str_components().rev()"]
+    pub fn rev_str_components<'a>(&'a self) -> Rev<StrComponents<'a>> {
+        self.str_components().rev()
     }
 }
 
@@ -1192,7 +1187,7 @@ mod tests {
                     let exps = exp.iter().map(|x| x.as_bytes()).collect::<Vec<&[u8]>>();
                     assert!(comps == exps, "components: Expected {:?}, found {:?}",
                             comps, exps);
-                    let comps = path.rev_components().collect::<Vec<&[u8]>>();
+                    let comps = path.components().rev().collect::<Vec<&[u8]>>();
                     let exps = exps.move_iter().rev().collect::<Vec<&[u8]>>();
                     assert!(comps == exps, "rev_components: Expected {:?}, found {:?}",
                             comps, exps);
@@ -1204,8 +1199,8 @@ mod tests {
                     let comps = path.components().collect::<Vec<&[u8]>>();
                     let exp: &[&[u8]] = [$(b!($($exp),*)),*];
                     assert_eq!(comps.as_slice(), exp);
-                    let comps = path.rev_components().collect::<Vec<&[u8]>>();
-                    let exp = exp.rev_iter().map(|&x|x).collect::<Vec<&[u8]>>();
+                    let comps = path.components().rev().collect::<Vec<&[u8]>>();
+                    let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>();
                     assert_eq!(comps, exp)
                 }
             )
@@ -1236,8 +1231,8 @@ mod tests {
                     let comps = path.str_components().collect::<Vec<Option<&str>>>();
                     let exp: &[Option<&str>] = $exp;
                     assert_eq!(comps.as_slice(), exp);
-                    let comps = path.rev_str_components().collect::<Vec<Option<&str>>>();
-                    let exp = exp.rev_iter().map(|&x|x).collect::<Vec<Option<&str>>>();
+                    let comps = path.str_components().rev().collect::<Vec<Option<&str>>>();
+                    let exp = exp.iter().rev().map(|&x|x).collect::<Vec<Option<&str>>>();
                     assert_eq!(comps, exp);
                 }
             )
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index 74ca8dc5785..758a76167cd 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -1,4 +1,4 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -37,15 +37,15 @@ pub type StrComponents<'a> = Map<'a, &'a str, Option<&'a str>,
 ///
 /// Each component is yielded as Option<&str> for compatibility with PosixPath, but
 /// every component in WindowsPath is guaranteed to be Some.
-pub type RevStrComponents<'a> = Rev<Map<'a, &'a str, Option<&'a str>,
-                                                 CharSplits<'a, char>>>;
+#[deprecated = "replaced by Rev<StrComponents<'a>>"]
+pub type RevStrComponents<'a> = Rev<StrComponents<'a>>;
 
 /// Iterator that yields successive components of a Path as &[u8]
 pub type Components<'a> = Map<'a, Option<&'a str>, &'a [u8],
                                     StrComponents<'a>>;
 /// Iterator that yields components of a Path in reverse as &[u8]
-pub type RevComponents<'a> = Map<'a, Option<&'a str>, &'a [u8],
-                                       RevStrComponents<'a>>;
+#[deprecated = "replaced by Rev<Components<'a>>"]
+pub type RevComponents<'a> = Rev<Components<'a>>;
 
 /// Represents a Windows path
 // Notes for Windows path impl:
@@ -633,7 +633,8 @@ impl Path {
 
     /// Returns an iterator that yields each component of the path in reverse as an Option<&str>
     /// See str_components() for details.
-    pub fn rev_str_components<'a>(&'a self) -> RevStrComponents<'a> {
+    #[deprecated = "replaced by .str_components().rev()"]
+    pub fn rev_str_components<'a>(&'a self) -> Rev<StrComponents<'a>> {
         self.str_components().rev()
     }
 
@@ -649,12 +650,9 @@ impl Path {
 
     /// Returns an iterator that yields each component of the path in reverse as a &[u8].
     /// See str_components() for details.
-    pub fn rev_components<'a>(&'a self) -> RevComponents<'a> {
-        fn convert<'a>(x: Option<&'a str>) -> &'a [u8] {
-            #![inline]
-            x.unwrap().as_bytes()
-        }
-        self.rev_str_components().map(convert)
+    #[deprecated = "replaced by .components().rev()"]
+    pub fn rev_components<'a>(&'a self) -> Rev<Components<'a>> {
+        self.components().rev()
     }
 
     fn equiv_prefix(&self, other: &Path) -> bool {
@@ -2239,9 +2237,9 @@ mod tests {
                                 .collect::<Vec<&str>>();
                     let exp: &[&str] = $exp;
                     assert_eq!(comps.as_slice(), exp);
-                    let comps = path.rev_str_components().map(|x|x.unwrap())
+                    let comps = path.str_components().rev().map(|x|x.unwrap())
                                 .collect::<Vec<&str>>();
-                    let exp = exp.rev_iter().map(|&x|x).collect::<Vec<&str>>();
+                    let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&str>>();
                     assert_eq!(comps, exp);
                 }
             );
@@ -2251,9 +2249,9 @@ mod tests {
                     let comps = path.str_components().map(|x|x.unwrap()).collect::<Vec<&str>>();
                     let exp: &[&str] = $exp;
                     assert_eq!(comps.as_slice(), exp);
-                    let comps = path.rev_str_components().map(|x|x.unwrap())
+                    let comps = path.str_components().rev().map(|x|x.unwrap())
                                 .collect::<Vec<&str>>();
-                    let exp = exp.rev_iter().map(|&x|x).collect::<Vec<&str>>();
+                    let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&str>>();
                     assert_eq!(comps, exp);
                 }
             )
@@ -2308,8 +2306,8 @@ mod tests {
                     let comps = path.components().collect::<Vec<&[u8]>>();
                     let exp: &[&[u8]] = $exp;
                     assert_eq!(comps.as_slice(), exp);
-                    let comps = path.rev_components().collect::<Vec<&[u8]>>();
-                    let exp = exp.rev_iter().map(|&x|x).collect::<Vec<&[u8]>>();
+                    let comps = path.components().rev().collect::<Vec<&[u8]>>();
+                    let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>();
                     assert_eq!(comps, exp);
                 }
             )
diff --git a/src/libstd/slice.rs b/src/libstd/slice.rs
index f5e064942e6..64f6b59be24 100644
--- a/src/libstd/slice.rs
+++ b/src/libstd/slice.rs
@@ -81,8 +81,6 @@ for &x in numbers.iter() {
 }
  ```
 
-* `.rev_iter()` returns an iterator with the same values as `.iter()`,
-  but going in the reverse order, starting with the back element.
 * `.mut_iter()` returns an iterator that allows modifying each value.
 * `.move_iter()` converts an owned vector into an iterator that
   moves out a value from the vector each iteration.
@@ -119,7 +117,6 @@ use result::{Ok, Err};
 use mem;
 use mem::size_of;
 use kinds::marker;
-use uint;
 use unstable::finally::try_finally;
 use raw::{Repr, Slice};
 use RawVec = raw::Vec;
@@ -148,7 +145,6 @@ pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] {
 /// match a predicate function.
 pub struct Splits<'a, T> {
     v: &'a [T],
-    n: uint,
     pred: |t: &T|: 'a -> bool,
     finished: bool
 }
@@ -158,11 +154,6 @@ impl<'a, T> Iterator<&'a [T]> for Splits<'a, T> {
     fn next(&mut self) -> Option<&'a [T]> {
         if self.finished { return None; }
 
-        if self.n == 0 {
-            self.finished = true;
-            return Some(self.v);
-        }
-
         match self.v.iter().position(|x| (self.pred)(x)) {
             None => {
                 self.finished = true;
@@ -171,7 +162,6 @@ impl<'a, T> Iterator<&'a [T]> for Splits<'a, T> {
             Some(idx) => {
                 let ret = Some(self.v.slice(0, idx));
                 self.v = self.v.slice(idx + 1, self.v.len());
-                self.n -= 1;
                 ret
             }
         }
@@ -180,38 +170,18 @@ impl<'a, T> Iterator<&'a [T]> for Splits<'a, T> {
     #[inline]
     fn size_hint(&self) -> (uint, Option<uint>) {
         if self.finished {
-            return (0, Some(0))
-        }
-        // if the predicate doesn't match anything, we yield one slice
-        // if it matches every element, we yield N+1 empty slices where
-        // N is either the number of elements or the number of splits.
-        match (self.v.len(), self.n) {
-            (0,_) => (1, Some(1)),
-            (_,0) => (1, Some(1)),
-            (l,n) => (1, cmp::min(l,n).checked_add(&1u))
+            (0, Some(0))
+        } else {
+            (1, Some(self.v.len() + 1))
         }
     }
 }
 
-/// An iterator over the slices of a vector separated by elements that
-/// match a predicate function, from back to front.
-pub struct RevSplits<'a, T> {
-    v: &'a [T],
-    n: uint,
-    pred: |t: &T|: 'a -> bool,
-    finished: bool
-}
-
-impl<'a, T> Iterator<&'a [T]> for RevSplits<'a, T> {
+impl<'a, T> DoubleEndedIterator<&'a [T]> for Splits<'a, T> {
     #[inline]
-    fn next(&mut self) -> Option<&'a [T]> {
+    fn next_back(&mut self) -> Option<&'a [T]> {
         if self.finished { return None; }
 
-        if self.n == 0 {
-            self.finished = true;
-            return Some(self.v);
-        }
-
         match self.v.iter().rposition(|x| (self.pred)(x)) {
             None => {
                 self.finished = true;
@@ -220,21 +190,42 @@ impl<'a, T> Iterator<&'a [T]> for RevSplits<'a, T> {
             Some(idx) => {
                 let ret = Some(self.v.slice(idx + 1, self.v.len()));
                 self.v = self.v.slice(0, idx);
-                self.n -= 1;
                 ret
             }
         }
     }
+}
 
+/// An iterator over the slices of a vector separated by elements that
+/// match a predicate function, splitting at most a fixed number of times.
+pub struct SplitsN<'a, T> {
+    iter: Splits<'a, T>,
+    count: uint,
+    invert: bool
+}
+
+impl<'a, T> Iterator<&'a [T]> for SplitsN<'a, T> {
     #[inline]
-    fn size_hint(&self) -> (uint, Option<uint>) {
-        if self.finished {
-            return (0, Some(0))
+    fn next(&mut self) -> Option<&'a [T]> {
+        if self.count == 0 {
+            if self.iter.finished {
+                None
+            } else {
+                self.iter.finished = true;
+                Some(self.iter.v)
+            }
+        } else {
+            self.count -= 1;
+            if self.invert { self.iter.next_back() } else { self.iter.next() }
         }
-        match (self.v.len(), self.n) {
-            (0,_) => (1, Some(1)),
-            (_,0) => (1, Some(1)),
-            (l,n) => (1, cmp::min(l,n).checked_add(&1u))
+    }
+
+    #[inline]
+    fn size_hint(&self) -> (uint, Option<uint>) {
+        if self.iter.finished {
+            (0, Some(0))
+        } else {
+            (1, Some(cmp::min(self.count, self.iter.v.len()) + 1))
         }
     }
 }
@@ -738,7 +729,8 @@ pub trait ImmutableVector<'a, T> {
     /// Returns an iterator over the vector
     fn iter(self) -> Items<'a, T>;
     /// Returns a reversed iterator over a vector
-    fn rev_iter(self) -> RevItems<'a, T>;
+    #[deprecated = "replaced by .iter().rev()"]
+    fn rev_iter(self) -> Rev<Items<'a, T>>;
     /// Returns an iterator over the subslices of the vector which are
     /// separated by elements that match `pred`.  The matched element
     /// is not contained in the subslices.
@@ -747,18 +739,19 @@ pub trait ImmutableVector<'a, T> {
     /// separated by elements that match `pred`, limited to splitting
     /// at most `n` times.  The matched element is not contained in
     /// the subslices.
-    fn splitn(self, n: uint, pred: |&T|: 'a -> bool) -> Splits<'a, T>;
+    fn splitn(self, n: uint, pred: |&T|: 'a -> bool) -> SplitsN<'a, T>;
     /// Returns an iterator over the subslices of the vector which are
     /// separated by elements that match `pred`. This starts at the
     /// end of the vector and works backwards.  The matched element is
     /// not contained in the subslices.
-    fn rsplit(self, pred: |&T|: 'a -> bool) -> RevSplits<'a, T>;
+    #[deprecated = "replaced by .split(pred).rev()"]
+    fn rsplit(self, pred: |&T|: 'a -> bool) -> Rev<Splits<'a, T>>;
     /// Returns an iterator over the subslices of the vector which are
     /// separated by elements that match `pred` limited to splitting
     /// at most `n` times. This starts at the end of the vector and
     /// works backwards.  The matched element is not contained in the
     /// subslices.
-    fn rsplitn(self,  n: uint, pred: |&T|: 'a -> bool) -> RevSplits<'a, T>;
+    fn rsplitn(self,  n: uint, pred: |&T|: 'a -> bool) -> SplitsN<'a, T>;
 
     /**
      * Returns an iterator over all contiguous windows of length
@@ -930,37 +923,41 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] {
     }
 
     #[inline]
-    fn rev_iter(self) -> RevItems<'a, T> {
+    #[deprecated = "replaced by .iter().rev()"]
+    fn rev_iter(self) -> Rev<Items<'a, T>> {
         self.iter().rev()
     }
 
     #[inline]
     fn split(self, pred: |&T|: 'a -> bool) -> Splits<'a, T> {
-        self.splitn(uint::MAX, pred)
-    }
-
-    #[inline]
-    fn splitn(self, n: uint, pred: |&T|: 'a -> bool) -> Splits<'a, T> {
         Splits {
             v: self,
-            n: n,
             pred: pred,
             finished: false
         }
     }
 
     #[inline]
-    fn rsplit(self, pred: |&T|: 'a -> bool) -> RevSplits<'a, T> {
-        self.rsplitn(uint::MAX, pred)
+    fn splitn(self, n: uint, pred: |&T|: 'a -> bool) -> SplitsN<'a, T> {
+        SplitsN {
+            iter: self.split(pred),
+            count: n,
+            invert: false
+        }
     }
 
     #[inline]
-    fn rsplitn(self, n: uint, pred: |&T|: 'a -> bool) -> RevSplits<'a, T> {
-        RevSplits {
-            v: self,
-            n: n,
-            pred: pred,
-            finished: false
+    #[deprecated = "replaced by .split(pred).rev()"]
+    fn rsplit(self, pred: |&T|: 'a -> bool) -> Rev<Splits<'a, T>> {
+        self.split(pred).rev()
+    }
+
+    #[inline]
+    fn rsplitn(self, n: uint, pred: |&T|: 'a -> bool) -> SplitsN<'a, T> {
+        SplitsN {
+            iter: self.split(pred),
+            count: n,
+            invert: true
         }
     }
 
@@ -1172,7 +1169,8 @@ pub trait OwnedVector<T> {
     fn move_iter(self) -> MoveItems<T>;
     /// Creates a consuming iterator that moves out of the vector in
     /// reverse order.
-    fn move_rev_iter(self) -> RevMoveItems<T>;
+    #[deprecated = "replaced by .move_iter().rev()"]
+    fn move_rev_iter(self) -> Rev<MoveItems<T>>;
 
     /**
      * Partitions the vector into two vectors `(A,B)`, where all
@@ -1192,7 +1190,8 @@ impl<T> OwnedVector<T> for ~[T] {
     }
 
     #[inline]
-    fn move_rev_iter(self) -> RevMoveItems<T> {
+    #[deprecated = "replaced by .move_iter().rev()"]
+    fn move_rev_iter(self) -> Rev<MoveItems<T>> {
         self.move_iter().rev()
     }
 
@@ -1447,7 +1446,8 @@ pub trait MutableVector<'a, T> {
     fn mut_last(self) -> Option<&'a mut T>;
 
     /// Returns a reversed iterator that allows modifying each value
-    fn mut_rev_iter(self) -> RevMutItems<'a, T>;
+    #[deprecated = "replaced by .mut_iter().rev()"]
+    fn mut_rev_iter(self) -> Rev<MutItems<'a, T>>;
 
     /// Returns an iterator over the mutable subslices of the vector
     /// which are separated by elements that match `pred`.  The
@@ -1719,7 +1719,8 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] {
     }
 
     #[inline]
-    fn mut_rev_iter(self) -> RevMutItems<'a, T> {
+    #[deprecated = "replaced by .mut_iter().rev()"]
+    fn mut_rev_iter(self) -> Rev<MutItems<'a, T>> {
         self.mut_iter().rev()
     }
 
@@ -2134,6 +2135,7 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
 }
 
 iterator!{struct Items -> *T, &'a T}
+#[deprecated = "replaced by Rev<Items<'a, T>>"]
 pub type RevItems<'a, T> = Rev<Items<'a, T>>;
 
 impl<'a, T> ExactSize<&'a T> for Items<'a, T> {}
@@ -2144,6 +2146,7 @@ impl<'a, T> Clone for Items<'a, T> {
 }
 
 iterator!{struct MutItems -> *mut T, &'a mut T}
+#[deprecated = "replaced by Rev<MutItems<'a, T>>"]
 pub type RevMutItems<'a, T> = Rev<MutItems<'a, T>>;
 
 /// An iterator over the subslices of the vector which are separated
@@ -2304,6 +2307,7 @@ impl<T> Drop for MoveItems<T> {
 }
 
 /// An iterator that moves out of a vector in reverse order.
+#[deprecated = "replaced by Rev<MoveItems<'a, T>>"]
 pub type RevMoveItems<T> = Rev<MoveItems<T>>;
 
 impl<A> FromIterator<A> for ~[A] {
@@ -3233,9 +3237,7 @@ mod tests {
         use iter::*;
         let mut xs = [1, 2, 5, 10, 11];
         assert_eq!(xs.iter().size_hint(), (5, Some(5)));
-        assert_eq!(xs.rev_iter().size_hint(), (5, Some(5)));
         assert_eq!(xs.mut_iter().size_hint(), (5, Some(5)));
-        assert_eq!(xs.mut_rev_iter().size_hint(), (5, Some(5)));
     }
 
     #[test]
@@ -3266,7 +3268,7 @@ mod tests {
         let xs = [1, 2, 5, 10, 11];
         let ys = [11, 10, 5, 2, 1];
         let mut i = 0;
-        for &x in xs.rev_iter() {
+        for &x in xs.iter().rev() {
             assert_eq!(x, ys[i]);
             i += 1;
         }
@@ -3277,7 +3279,7 @@ mod tests {
     fn test_mut_rev_iterator() {
         use iter::*;
         let mut xs = [1u, 2, 3, 4, 5];
-        for (i,x) in xs.mut_rev_iter().enumerate() {
+        for (i,x) in xs.mut_iter().rev().enumerate() {
             *x += i;
         }
         assert!(xs == [5, 5, 5, 5, 5])
@@ -3294,7 +3296,7 @@ mod tests {
     fn test_move_rev_iterator() {
         use iter::*;
         let xs = ~[1u,2,3,4,5];
-        assert_eq!(xs.move_rev_iter().fold(0, |a: uint, b: uint| 10*a + b), 54321);
+        assert_eq!(xs.move_iter().rev().fold(0, |a: uint, b: uint| 10*a + b), 54321);
     }
 
     #[test]
@@ -3335,17 +3337,17 @@ mod tests {
     fn test_rsplitator() {
         let xs = &[1i,2,3,4,5];
 
-        assert_eq!(xs.rsplit(|x| *x % 2 == 0).collect::<~[&[int]]>(),
+        assert_eq!(xs.split(|x| *x % 2 == 0).rev().collect::<~[&[int]]>(),
                    ~[&[5], &[3], &[1]]);
-        assert_eq!(xs.rsplit(|x| *x == 1).collect::<~[&[int]]>(),
+        assert_eq!(xs.split(|x| *x == 1).rev().collect::<~[&[int]]>(),
                    ~[&[2,3,4,5], &[]]);
-        assert_eq!(xs.rsplit(|x| *x == 5).collect::<~[&[int]]>(),
+        assert_eq!(xs.split(|x| *x == 5).rev().collect::<~[&[int]]>(),
                    ~[&[], &[1,2,3,4]]);
-        assert_eq!(xs.rsplit(|x| *x == 10).collect::<~[&[int]]>(),
+        assert_eq!(xs.split(|x| *x == 10).rev().collect::<~[&[int]]>(),
                    ~[&[1,2,3,4,5]]);
 
         let xs: &[int] = &[];
-        assert_eq!(xs.rsplit(|x| *x == 5).collect::<~[&[int]]>(), ~[&[]]);
+        assert_eq!(xs.split(|x| *x == 5).rev().collect::<~[&[int]]>(), ~[&[]]);
     }
 
     #[test]
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 99f1c66e702..bc7943dd777 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -343,12 +343,10 @@ impl<'a> DoubleEndedIterator<(uint, char)> for CharOffsets<'a> {
     }
 }
 
-/// External iterator for a string's characters in reverse order.
-/// Use with the `std::iter` module.
+#[deprecated = "replaced by Rev<Chars<'a>>"]
 pub type RevChars<'a> = Rev<Chars<'a>>;
 
-/// External iterator for a string's characters and their byte offsets in reverse order.
-/// Use with the `std::iter` module.
+#[deprecated = "replaced by Rev<CharOffsets<'a>>"]
 pub type RevCharOffsets<'a> = Rev<CharOffsets<'a>>;
 
 /// External iterator for a string's bytes.
@@ -356,8 +354,7 @@ pub type RevCharOffsets<'a> = Rev<CharOffsets<'a>>;
 pub type Bytes<'a> =
     Map<'a, &'a u8, u8, slice::Items<'a, u8>>;
 
-/// External iterator for a string's bytes in reverse order.
-/// Use with the `std::iter` module.
+#[deprecated = "replaced by Rev<Bytes<'a>>"]
 pub type RevBytes<'a> = Rev<Bytes<'a>>;
 
 /// An iterator over the substrings of a string, separated by `sep`.
@@ -372,8 +369,7 @@ pub struct CharSplits<'a, Sep> {
     finished: bool,
 }
 
-/// An iterator over the substrings of a string, separated by `sep`,
-/// starting from the back of the string.
+#[deprecated = "replaced by Rev<CharSplits<'a, Sep>>"]
 pub type RevCharSplits<'a, Sep> = Rev<CharSplits<'a, Sep>>;
 
 /// An iterator over the substrings of a string, separated by `sep`,
@@ -462,7 +458,7 @@ for CharSplits<'a, Sep> {
                 }
             }
         } else {
-            for (idx, ch) in self.string.char_indices_rev() {
+            for (idx, ch) in self.string.char_indices().rev() {
                 if self.sep.matches(ch) {
                     next_split = Some((idx, self.string.char_range_at(idx).next));
                     break;
@@ -1626,21 +1622,23 @@ pub trait StrSlice<'a> {
     /// ```
     fn chars(&self) -> Chars<'a>;
 
-    /// An iterator over the characters of `self`, in reverse order.
-    fn chars_rev(&self) -> RevChars<'a>;
+    /// Do not use this - it is deprecated.
+    #[deprecated = "replaced by .chars().rev()"]
+    fn chars_rev(&self) -> Rev<Chars<'a>>;
 
     /// An iterator over the bytes of `self`
     fn bytes(&self) -> Bytes<'a>;
 
-    /// An iterator over the bytes of `self`, in reverse order
-    fn bytes_rev(&self) -> RevBytes<'a>;
+    /// Do not use this - it is deprecated.
+    #[deprecated = "replaced by .bytes().rev()"]
+    fn bytes_rev(&self) -> Rev<Bytes<'a>>;
 
     /// An iterator over the characters of `self` and their byte offsets.
     fn char_indices(&self) -> CharOffsets<'a>;
 
-    /// An iterator over the characters of `self` and their byte offsets,
-    /// in reverse order.
-    fn char_indices_rev(&self) -> RevCharOffsets<'a>;
+    /// Do not use this - it is deprecated.
+    #[deprecated = "replaced by .char_indices().rev()"]
+    fn char_indices_rev(&self) -> Rev<CharOffsets<'a>>;
 
     /// An iterator over substrings of `self`, separated by characters
     /// matched by `sep`.
@@ -1691,25 +1689,21 @@ pub trait StrSlice<'a> {
     ///
     /// let v: ~[&str] = "A..B..".split_terminator('.').collect();
     /// assert_eq!(v, ~["A", "", "B", ""]);
-    /// ```
-    fn split_terminator<Sep: CharEq>(&self, sep: Sep) -> CharSplits<'a, Sep>;
-
-    /// An iterator over substrings of `self`, separated by characters
-    /// matched by `sep`, in reverse order.
-    ///
-    /// # Example
     ///
-    /// ```rust
-    /// let v: ~[&str] = "Mary had a little lamb".rsplit(' ').collect();
+    /// let v: ~[&str] = "Mary had a little lamb".split(' ').rev().collect();
     /// assert_eq!(v, ~["lamb", "little", "a", "had", "Mary"]);
     ///
-    /// let v: ~[&str] = "abc1def2ghi".rsplit(|c: char| c.is_digit()).collect();
+    /// let v: ~[&str] = "abc1def2ghi".split(|c: char| c.is_digit()).rev().collect();
     /// assert_eq!(v, ~["ghi", "def", "abc"]);
     ///
-    /// let v: ~[&str] = "lionXXtigerXleopard".rsplit('X').collect();
+    /// let v: ~[&str] = "lionXXtigerXleopard".split('X').rev().collect();
     /// assert_eq!(v, ~["leopard", "tiger", "", "lion"]);
     /// ```
-    fn rsplit<Sep: CharEq>(&self, sep: Sep) -> RevCharSplits<'a, Sep>;
+    fn split_terminator<Sep: CharEq>(&self, sep: Sep) -> CharSplits<'a, Sep>;
+
+    /// Do not use this - it is deprecated.
+    #[deprecated = "replaced by .split(sep).rev()"]
+    fn rsplit<Sep: CharEq>(&self, sep: Sep) -> Rev<CharSplits<'a, Sep>>;
 
     /// An iterator over substrings of `self`, separated by characters
     /// matched by `sep`, starting from the end of the string.
@@ -2281,7 +2275,8 @@ impl<'a> StrSlice<'a> for &'a str {
     }
 
     #[inline]
-    fn chars_rev(&self) -> RevChars<'a> {
+    #[deprecated = "replaced by .chars().rev()"]
+    fn chars_rev(&self) -> Rev<Chars<'a>> {
         self.chars().rev()
     }
 
@@ -2291,7 +2286,8 @@ impl<'a> StrSlice<'a> for &'a str {
     }
 
     #[inline]
-    fn bytes_rev(&self) -> RevBytes<'a> {
+    #[deprecated = "replaced by .bytes().rev()"]
+    fn bytes_rev(&self) -> Rev<Bytes<'a>> {
         self.bytes().rev()
     }
 
@@ -2301,7 +2297,8 @@ impl<'a> StrSlice<'a> for &'a str {
     }
 
     #[inline]
-    fn char_indices_rev(&self) -> RevCharOffsets<'a> {
+    #[deprecated = "replaced by .char_indices().rev()"]
+    fn char_indices_rev(&self) -> Rev<CharOffsets<'a>> {
         self.char_indices().rev()
     }
 
@@ -2336,7 +2333,8 @@ impl<'a> StrSlice<'a> for &'a str {
     }
 
     #[inline]
-    fn rsplit<Sep: CharEq>(&self, sep: Sep) -> RevCharSplits<'a, Sep> {
+    #[deprecated = "replaced by .split(sep).rev()"]
+    fn rsplit<Sep: CharEq>(&self, sep: Sep) -> Rev<CharSplits<'a, Sep>> {
         self.split(sep).rev()
     }
 
@@ -2656,7 +2654,7 @@ impl<'a> StrSlice<'a> for &'a str {
         if search.only_ascii() {
             self.bytes().rposition(|b| search.matches(b as char))
         } else {
-            for (index, c) in self.char_indices_rev() {
+            for (index, c) in self.char_indices().rev() {
                 if search.matches(c) { return Some(index); }
             }
             None
@@ -3573,7 +3571,7 @@ mod tests {
         let s = "ศไทย中华Việt Nam".to_owned();
         let v = ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
         let mut pos = s.len();
-        for ch in v.rev_iter() {
+        for ch in v.iter().rev() {
             assert!(s.char_at_reverse(pos) == *ch);
             pos -= from_char(*ch).len();
         }
@@ -3673,7 +3671,7 @@ mod tests {
         let v = ~['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ'];
 
         let mut pos = 0;
-        let mut it = s.chars_rev();
+        let mut it = s.chars().rev();
 
         for c in it {
             assert_eq!(c, v[pos]);
@@ -3716,7 +3714,7 @@ mod tests {
         ];
         let mut pos = v.len();
 
-        for b in s.bytes_rev() {
+        for b in s.bytes().rev() {
             pos -= 1;
             assert_eq!(b, v[pos]);
         }
@@ -3748,7 +3746,7 @@ mod tests {
         let v = ['m', 'a', 'N', ' ', 't', 'ệ','i','V','华','中','ย','ท','ไ','ศ'];
 
         let mut pos = 0;
-        let mut it = s.char_indices_rev();
+        let mut it = s.char_indices().rev();
 
         for c in it {
             assert_eq!(c, (p[pos], v[pos]));
@@ -3765,14 +3763,14 @@ mod tests {
         let split: ~[&str] = data.split(' ').collect();
         assert_eq!( split, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
 
-        let mut rsplit: ~[&str] = data.rsplit(' ').collect();
+        let mut rsplit: ~[&str] = data.split(' ').rev().collect();
         rsplit.reverse();
         assert_eq!(rsplit, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
 
         let split: ~[&str] = data.split(|c: char| c == ' ').collect();
         assert_eq!( split, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
 
-        let mut rsplit: ~[&str] = data.rsplit(|c: char| c == ' ').collect();
+        let mut rsplit: ~[&str] = data.split(|c: char| c == ' ').rev().collect();
         rsplit.reverse();
         assert_eq!(rsplit, ~["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
 
@@ -3780,14 +3778,14 @@ mod tests {
         let split: ~[&str] = data.split('ä').collect();
         assert_eq!( split, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
 
-        let mut rsplit: ~[&str] = data.rsplit('ä').collect();
+        let mut rsplit: ~[&str] = data.split('ä').rev().collect();
         rsplit.reverse();
         assert_eq!(rsplit, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
 
         let split: ~[&str] = data.split(|c: char| c == 'ä').collect();
         assert_eq!( split, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
 
-        let mut rsplit: ~[&str] = data.rsplit(|c: char| c == 'ä').collect();
+        let mut rsplit: ~[&str] = data.split(|c: char| c == 'ä').rev().collect();
         rsplit.reverse();
         assert_eq!(rsplit, ~["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
     }
@@ -4103,7 +4101,7 @@ mod bench {
         let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
         let len = s.char_len();
 
-        b.iter(|| assert_eq!(s.chars_rev().len(), len));
+        b.iter(|| assert_eq!(s.chars().rev().len(), len));
     }
 
     #[bench]
@@ -4119,7 +4117,7 @@ mod bench {
         let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb";
         let len = s.char_len();
 
-        b.iter(|| assert_eq!(s.char_indices_rev().len(), len));
+        b.iter(|| assert_eq!(s.char_indices().rev().len(), len));
     }
 
     #[bench]