diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-05 03:59:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-05 03:59:35 +0200 |
| commit | 38ce68768dd25f8aeeb2653e187473d113c03f03 (patch) | |
| tree | ee51dc5dfc51c2b570ef3f3d56616478840971d7 /src/libcore | |
| parent | ee437eb5d45a757f9cfd156de1c1db988c60650a (diff) | |
| parent | 0e597d4c479b4533e38016b1adbe565b44aab922 (diff) | |
| download | rust-38ce68768dd25f8aeeb2653e187473d113c03f03.tar.gz rust-38ce68768dd25f8aeeb2653e187473d113c03f03.zip | |
Rollup merge of #63549 - sfanxiang:rev-rposition, r=scottmcm
Rev::rposition counts from the wrong end Introduced in #43074. cc @SimonSapin
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/iter/adapters/mod.rs | 7 | ||||
| -rw-r--r-- | src/libcore/tests/iter.rs | 6 |
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] = |
