about summary refs log tree commit diff
diff options
context:
space:
mode:
authorXiang Fan <sfanxiang@gmail.com>2019-08-30 21:17:36 +0800
committerXiang Fan <sfanxiang@gmail.com>2019-08-30 21:17:36 +0800
commit0e597d4c479b4533e38016b1adbe565b44aab922 (patch)
tree64f6c60519cdd2707fa158eee5a9c1ecc7bfe3c4
parent19a38de68a8de14fe49e96b315db026bd57b9696 (diff)
downloadrust-0e597d4c479b4533e38016b1adbe565b44aab922.tar.gz
rust-0e597d4c479b4533e38016b1adbe565b44aab922.zip
Rev::rposition counts from the wrong end
Because of a compiler bug that adding `Self: ExactSizeIterator` makes
the compiler forget `Self::Item` is `<I as Iterator>::Item`, we remove
this specialization for now.
-rw-r--r--src/libcore/iter/adapters/mod.rs7
-rw-r--r--src/libcore/tests/iter.rs6
2 files changed, 6 insertions, 7 deletions
diff --git a/src/libcore/iter/adapters/mod.rs b/src/libcore/iter/adapters/mod.rs
index f50781890ab..8e1ac6082c8 100644
--- a/src/libcore/iter/adapters/mod.rs
+++ b/src/libcore/iter/adapters/mod.rs
@@ -66,13 +66,6 @@ impl<I> Iterator for Rev<I> where I: DoubleEndedIterator {
     {
         self.iter.rfind(predicate)
     }
-
-    #[inline]
-    fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
-        P: FnMut(Self::Item) -> bool
-    {
-        self.iter.position(predicate)
-    }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs
index 3a4f76852a0..8e0658d87c1 100644
--- a/src/libcore/tests/iter.rs
+++ b/src/libcore/tests/iter.rs
@@ -1689,6 +1689,12 @@ fn test_rposition() {
 }
 
 #[test]
+fn test_rev_rposition() {
+    let v = [0, 0, 1, 1];
+    assert_eq!(v.iter().rev().rposition(|&x| x == 1), Some(1));
+}
+
+#[test]
 #[should_panic]
 fn test_rposition_panic() {
     let v: [(Box<_>, Box<_>); 4] =