From 04269c929644668fd49a9e4441e36c33c2dfd9d7 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 28 Oct 2017 10:37:59 -0700 Subject: [PATCH] More folds that might as well just use the default impl Allows deleting a SearchResult inherent, too. --- src/libcore/iter/mod.rs | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index c032c94c0d07b..c271a0cada91d 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -389,16 +389,6 @@ impl SearchResult { } } -impl SearchResult { - #[inline] - fn into_inner(self) -> T { - match self { - SearchResult::Found(a) | - SearchResult::NotFound(a) => a - } - } -} - impl SearchResult { #[inline] fn from_try(r: R) -> Self { @@ -2063,21 +2053,6 @@ impl Iterator for TakeWhile }).into_try() } } - - #[inline] - fn fold(mut self, init: Acc, mut fold: Fold) -> Acc - where Fold: FnMut(Acc, Self::Item) -> Acc, - { - if self.flag { - init - } else { - let mut p = self.predicate; - self.iter.try_fold(init, move |acc, x| { - if p(&x) { SearchResult::NotFound(fold(acc, x)) } - else { SearchResult::Found(acc) } - }).into_inner() - } - } } #[unstable(feature = "fused", issue = "35602")] @@ -2217,22 +2192,6 @@ impl DoubleEndedIterator for Skip where I: DoubleEndedIterator + ExactSize }).into_try() } } - - fn rfold(mut self, init: Acc, mut fold: Fold) -> Acc - where Fold: FnMut(Acc, Self::Item) -> Acc, - { - let mut n = self.len(); - if n == 0 { - init - } else { - self.iter.try_rfold(init, move |acc, x| { - n -= 1; - let acc = fold(acc, x); - if n == 0 { SearchResult::Found(acc) } - else { SearchResult::NotFound(acc) } - }).into_inner() - } - } } #[unstable(feature = "fused", issue = "35602")]