Skip to content

Commit d8aebea

Browse files
committed
Simplified type signature
1 parent 69b18f7 commit d8aebea

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

library/core/src/iter/adapters/dedup.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,18 @@ impl<T: PartialEq> FnMut<(&T, &T)> for ByPartialEq {
9494
/// [`Iterator::dedup_by_key`]: Iterator::dedup_by_key
9595
#[unstable(feature = "iter_dedup", reason = "recently added", issue = "83748")]
9696
#[derive(Debug, Clone, Copy)]
97-
pub struct Dedup<I, F, T> {
97+
pub struct Dedup<I, F>
98+
where
99+
I: Iterator,
100+
{
98101
inner: I,
99102
same_bucket: F,
100-
last: Option<T>,
103+
last: Option<I::Item>,
101104
}
102105

103-
impl<I, F, T> Dedup<I, F, T>
106+
impl<I, F> Dedup<I, F>
104107
where
105-
I: Iterator<Item = T>,
108+
I: Iterator,
106109
{
107110
pub(crate) fn new(inner: I, same_bucket: F) -> Self {
108111
let mut inner = inner;
@@ -111,12 +114,12 @@ where
111114
}
112115

113116
#[unstable(feature = "iter_dedup", reason = "recently added", issue = "83748")]
114-
impl<I, F, T> Iterator for Dedup<I, F, T>
117+
impl<I, F> Iterator for Dedup<I, F>
115118
where
116-
I: Iterator<Item = T>,
117-
F: FnMut(&T, &T) -> bool,
119+
I: Iterator,
120+
F: FnMut(&I::Item, &I::Item) -> bool,
118121
{
119-
type Item = T;
122+
type Item = I::Item;
120123

121124
fn next(&mut self) -> Option<Self::Item> {
122125
let last_item = self.last.as_ref()?;
@@ -143,7 +146,7 @@ where
143146
}
144147

145148
#[unstable(feature = "iter_dedup", reason = "recently added", issue = "83748")]
146-
unsafe impl<S, I, F, T> SourceIter for Dedup<I, F, T>
149+
unsafe impl<S, I, F> SourceIter for Dedup<I, F>
147150
where
148151
S: Iterator,
149152
I: Iterator + SourceIter<Source = S>,
@@ -157,9 +160,9 @@ where
157160
}
158161

159162
#[unstable(feature = "iter_dedup", reason = "recently added", issue = "83748")]
160-
unsafe impl<I, F, T> InPlaceIterable for Dedup<I, F, T>
163+
unsafe impl<I, F> InPlaceIterable for Dedup<I, F>
161164
where
162-
I: InPlaceIterable<Item = T>,
163-
F: FnMut(&T, &T) -> bool,
165+
I: InPlaceIterable,
166+
F: FnMut(&I::Item, &I::Item) -> bool,
164167
{
165168
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ pub trait Iterator {
17261726
/// ```
17271727
#[unstable(feature = "iter_dedup", reason = "recently added", issue = "83748")]
17281728
#[inline]
1729-
fn dedup(self) -> Dedup<Self, ByPartialEq, Self::Item>
1729+
fn dedup(self) -> Dedup<Self, ByPartialEq>
17301730
where
17311731
Self: Sized,
17321732
Self::Item: PartialEq,
@@ -1773,7 +1773,7 @@ pub trait Iterator {
17731773
/// ```
17741774
#[unstable(feature = "iter_dedup", reason = "recently added", issue = "83748")]
17751775
#[inline]
1776-
fn dedup_by<F>(self, same_bucket: F) -> Dedup<Self, F, Self::Item>
1776+
fn dedup_by<F>(self, same_bucket: F) -> Dedup<Self, F>
17771777
where
17781778
Self: Sized,
17791779
F: FnMut(&Self::Item, &Self::Item) -> bool,
@@ -1817,7 +1817,7 @@ pub trait Iterator {
18171817
/// ```
18181818
#[unstable(feature = "iter_dedup", reason = "recently added", issue = "83748")]
18191819
#[inline]
1820-
fn dedup_by_key<F, K>(self, key: F) -> Dedup<Self, ByKey<F>, Self::Item>
1820+
fn dedup_by_key<F, K>(self, key: F) -> Dedup<Self, ByKey<F>>
18211821
where
18221822
Self: Sized,
18231823
F: FnMut(&Self::Item) -> K,

0 commit comments

Comments
 (0)