Skip to content

Commit 04269c9

Browse files
committed
More folds that might as well just use the default impl
Allows deleting a SearchResult inherent, too.
1 parent b725535 commit 04269c9

File tree

1 file changed

+0
-41
lines changed

1 file changed

+0
-41
lines changed

src/libcore/iter/mod.rs

-41
Original file line numberDiff line numberDiff line change
@@ -389,16 +389,6 @@ impl<S, T> SearchResult<S, T> {
389389
}
390390
}
391391

392-
impl<T> SearchResult<T, T> {
393-
#[inline]
394-
fn into_inner(self) -> T {
395-
match self {
396-
SearchResult::Found(a) |
397-
SearchResult::NotFound(a) => a
398-
}
399-
}
400-
}
401-
402392
impl<R: Try> SearchResult<R::Ok, R> {
403393
#[inline]
404394
fn from_try(r: R) -> Self {
@@ -2063,21 +2053,6 @@ impl<I: Iterator, P> Iterator for TakeWhile<I, P>
20632053
}).into_try()
20642054
}
20652055
}
2066-
2067-
#[inline]
2068-
fn fold<Acc, Fold>(mut self, init: Acc, mut fold: Fold) -> Acc
2069-
where Fold: FnMut(Acc, Self::Item) -> Acc,
2070-
{
2071-
if self.flag {
2072-
init
2073-
} else {
2074-
let mut p = self.predicate;
2075-
self.iter.try_fold(init, move |acc, x| {
2076-
if p(&x) { SearchResult::NotFound(fold(acc, x)) }
2077-
else { SearchResult::Found(acc) }
2078-
}).into_inner()
2079-
}
2080-
}
20812056
}
20822057

20832058
#[unstable(feature = "fused", issue = "35602")]
@@ -2217,22 +2192,6 @@ impl<I> DoubleEndedIterator for Skip<I> where I: DoubleEndedIterator + ExactSize
22172192
}).into_try()
22182193
}
22192194
}
2220-
2221-
fn rfold<Acc, Fold>(mut self, init: Acc, mut fold: Fold) -> Acc
2222-
where Fold: FnMut(Acc, Self::Item) -> Acc,
2223-
{
2224-
let mut n = self.len();
2225-
if n == 0 {
2226-
init
2227-
} else {
2228-
self.iter.try_rfold(init, move |acc, x| {
2229-
n -= 1;
2230-
let acc = fold(acc, x);
2231-
if n == 0 { SearchResult::Found(acc) }
2232-
else { SearchResult::NotFound(acc) }
2233-
}).into_inner()
2234-
}
2235-
}
22362195
}
22372196

22382197
#[unstable(feature = "fused", issue = "35602")]

0 commit comments

Comments
 (0)