Skip to content

Commit 5c056ed

Browse files
committed
Rename Iterator::fold_first to reduce.
1 parent e708cbd commit 5c056ed

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl GenericArgs<'_> {
358358
.iter()
359359
.filter(|arg| !arg.is_synthetic())
360360
.map(|arg| arg.span())
361-
.fold_first(|span1, span2| span1.to(span2))
361+
.reduce(|span1, span2| span1.to(span2))
362362
}
363363

364364
/// Returns span encompassing arguments and their surrounding `<>` or `()`

library/core/src/iter/traits/iterator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,7 @@ pub trait Iterator {
21382138
/// where I: Iterator,
21392139
/// I::Item: Ord,
21402140
/// {
2141-
/// iter.fold_first(|a, b| {
2141+
/// iter.reduce(|a, b| {
21422142
/// if a >= b { a } else { b }
21432143
/// })
21442144
/// }
@@ -2150,7 +2150,7 @@ pub trait Iterator {
21502150
/// ```
21512151
#[inline]
21522152
#[unstable(feature = "iterator_fold_self", issue = "68125")]
2153-
fn fold_first<F>(mut self, f: F) -> Option<Self::Item>
2153+
fn reduce<F>(mut self, f: F) -> Option<Self::Item>
21542154
where
21552155
Self: Sized,
21562156
F: FnMut(Self::Item, Self::Item) -> Self::Item,
@@ -2647,7 +2647,7 @@ pub trait Iterator {
26472647
move |x, y| cmp::max_by(x, y, &mut compare)
26482648
}
26492649

2650-
self.fold_first(fold(compare))
2650+
self.reduce(fold(compare))
26512651
}
26522652

26532653
/// Returns the element that gives the minimum value from the
@@ -2707,7 +2707,7 @@ pub trait Iterator {
27072707
move |x, y| cmp::min_by(x, y, &mut compare)
27082708
}
27092709

2710-
self.fold_first(fold(compare))
2710+
self.reduce(fold(compare))
27112711
}
27122712

27132713
/// Reverses an iterator's direction.

0 commit comments

Comments
 (0)