From 5c056ed2f5d118cfd5d936b10a9c34d8813a6c09 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 7 Dec 2020 21:23:29 +0100 Subject: [PATCH] Rename Iterator::fold_first to reduce. --- compiler/rustc_hir/src/hir.rs | 2 +- library/core/src/iter/traits/iterator.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 1c16dc02667..6487b23a6a6 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -358,7 +358,7 @@ impl GenericArgs<'_> { .iter() .filter(|arg| !arg.is_synthetic()) .map(|arg| arg.span()) - .fold_first(|span1, span2| span1.to(span2)) + .reduce(|span1, span2| span1.to(span2)) } /// Returns span encompassing arguments and their surrounding `<>` or `()` diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index c961e2964a9..7a3700d6923 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -2138,7 +2138,7 @@ pub trait Iterator { /// where I: Iterator, /// I::Item: Ord, /// { - /// iter.fold_first(|a, b| { + /// iter.reduce(|a, b| { /// if a >= b { a } else { b } /// }) /// } @@ -2150,7 +2150,7 @@ pub trait Iterator { /// ``` #[inline] #[unstable(feature = "iterator_fold_self", issue = "68125")] - fn fold_first(mut self, f: F) -> Option + fn reduce(mut self, f: F) -> Option where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item, @@ -2647,7 +2647,7 @@ pub trait Iterator { move |x, y| cmp::max_by(x, y, &mut compare) } - self.fold_first(fold(compare)) + self.reduce(fold(compare)) } /// Returns the element that gives the minimum value from the @@ -2707,7 +2707,7 @@ pub trait Iterator { move |x, y| cmp::min_by(x, y, &mut compare) } - self.fold_first(fold(compare)) + self.reduce(fold(compare)) } /// Reverses an iterator's direction.