Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 02cb1e9

Browse files
authoredJun 13, 2024
Rollup merge of rust-lang#126347 - slanterns:try_simplify, r=scottmcm
Simplify `try_*`'s signature on `Iterator` Inspired by rust-lang#126249 (comment). r? `@scottmcm` (Seems there's no need to explicitly use `<Self as Iterator>::Item`? I only find this occurrence across the whole file.)
2 parents 9921cd2 + 93583a6 commit 02cb1e9

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed
 

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

+11-10
Original file line numberDiff line numberDiff line change
@@ -2080,8 +2080,7 @@ pub trait Iterator {
20802080
fn try_collect<B>(&mut self) -> ChangeOutputType<Self::Item, B>
20812081
where
20822082
Self: Sized,
2083-
<Self as Iterator>::Item: Try,
2084-
<<Self as Iterator>::Item as Try>::Residual: Residual<B>,
2083+
Self::Item: Try<Residual: Residual<B>>,
20852084
B: FromIterator<<Self::Item as Try>::Output>,
20862085
{
20872086
try_process(ByRefSized(self), |i| i.collect())
@@ -2689,12 +2688,13 @@ pub trait Iterator {
26892688
#[inline]
26902689
#[unstable(feature = "iterator_try_reduce", reason = "new API", issue = "87053")]
26912690
#[rustc_do_not_const_check]
2692-
fn try_reduce<F, R>(&mut self, f: F) -> ChangeOutputType<R, Option<R::Output>>
2691+
fn try_reduce<R>(
2692+
&mut self,
2693+
f: impl FnMut(Self::Item, Self::Item) -> R,
2694+
) -> ChangeOutputType<R, Option<R::Output>>
26932695
where
26942696
Self: Sized,
2695-
F: FnMut(Self::Item, Self::Item) -> R,
2696-
R: Try<Output = Self::Item>,
2697-
R::Residual: Residual<Option<Self::Item>>,
2697+
R: Try<Output = Self::Item, Residual: Residual<Option<Self::Item>>>,
26982698
{
26992699
let first = match self.next() {
27002700
Some(i) => i,
@@ -2956,12 +2956,13 @@ pub trait Iterator {
29562956
#[inline]
29572957
#[unstable(feature = "try_find", reason = "new API", issue = "63178")]
29582958
#[rustc_do_not_const_check]
2959-
fn try_find<F, R>(&mut self, f: F) -> ChangeOutputType<R, Option<Self::Item>>
2959+
fn try_find<R>(
2960+
&mut self,
2961+
f: impl FnMut(&Self::Item) -> R,
2962+
) -> ChangeOutputType<R, Option<Self::Item>>
29602963
where
29612964
Self: Sized,
2962-
F: FnMut(&Self::Item) -> R,
2963-
R: Try<Output = bool>,
2964-
R::Residual: Residual<Option<Self::Item>>,
2965+
R: Try<Output = bool, Residual: Residual<Option<Self::Item>>>,
29652966
{
29662967
#[inline]
29672968
fn check<I, V, R>(

0 commit comments

Comments
 (0)
Failed to load comments.