Skip to content

Commit

Permalink
fix clippy::type_repetition_in_bounds
Browse files Browse the repository at this point in the history
https://rust-lang.github.io/rust-clippy/master/index.html#/type_repetition_in_bounds

`CircularTupleWindows` even had a duplicate bound.

Co-Authored-By: Marcel Hellwig <[email protected]>
  • Loading branch information
2 people authored and Philippe-Cholet committed Jan 10, 2024
1 parent 6938a61 commit a638f83
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 26 deletions.
5 changes: 3 additions & 2 deletions src/adaptors/coalesce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ where
f: F,
}

impl<I: Clone, F: Clone, C> Clone for CoalesceBy<I, F, C>
impl<I, F, C> Clone for CoalesceBy<I, F, C>
where
I: Iterator,
I: Clone + Iterator,
F: Clone,
C: CountItem<I::Item>,
C::CItem: Clone,
{
Expand Down
4 changes: 2 additions & 2 deletions src/free.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ where
///
/// assert_eq!(cloned(b"abc").next(), Some(b'a'));
/// ```
pub fn cloned<'a, I, T: 'a>(iterable: I) -> iter::Cloned<I::IntoIter>
pub fn cloned<'a, I, T>(iterable: I) -> iter::Cloned<I::IntoIter>
where
I: IntoIterator<Item = &'a T>,
T: Clone,
T: Clone + 'a,
{
iterable.into_iter().cloned()
}
Expand Down
24 changes: 14 additions & 10 deletions src/groupbylazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ trait KeyFunction<A> {
fn call_mut(&mut self, arg: A) -> Self::Key;
}

impl<A, K, F: ?Sized> KeyFunction<A> for F
impl<A, K, F> KeyFunction<A> for F
where
F: FnMut(A) -> K,
F: FnMut(A) -> K + ?Sized,
{
type Key = K;
#[inline]
Expand Down Expand Up @@ -370,10 +370,12 @@ where
///
/// See [`.group_by()`](crate::Itertools::group_by) for more information.
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
pub struct Groups<'a, K: 'a, I: 'a, F: 'a>
pub struct Groups<'a, K, I, F>
where
I: Iterator,
I: Iterator + 'a,
I::Item: 'a,
K: 'a,
F: 'a,
{
parent: &'a GroupBy<K, I, F>,
}
Expand Down Expand Up @@ -409,10 +411,12 @@ where
/// An iterator for the elements in a single group.
///
/// Iterator element type is `I::Item`.
pub struct Group<'a, K: 'a, I: 'a, F: 'a>
pub struct Group<'a, K, I, F>
where
I: Iterator,
I: Iterator + 'a,
I::Item: 'a,
K: 'a,
F: 'a,
{
parent: &'a GroupBy<K, I, F>,
index: usize,
Expand Down Expand Up @@ -537,9 +541,9 @@ where
/// See [`.chunks()`](crate::Itertools::chunks) for more information.
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[derive(Clone)]
pub struct Chunks<'a, I: 'a>
pub struct Chunks<'a, I>
where
I: Iterator,
I: Iterator + 'a,
I::Item: 'a,
{
parent: &'a IntoChunks<I>,
Expand Down Expand Up @@ -568,9 +572,9 @@ where
/// An iterator for the elements in a single chunk.
///
/// Iterator element type is `I::Item`.
pub struct Chunk<'a, I: 'a>
pub struct Chunk<'a, I>
where
I: Iterator,
I: Iterator + 'a,
I::Item: 'a,
{
parent: &'a IntoChunks<I>,
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2124,8 +2124,7 @@ pub trait Itertools: Iterator {
/// ```
fn dropping_back(mut self, n: usize) -> Self
where
Self: Sized,
Self: DoubleEndedIterator,
Self: Sized + DoubleEndedIterator,
{
if n > 0 {
(&mut self).rev().nth(n - 1);
Expand Down Expand Up @@ -3962,7 +3961,7 @@ pub trait Itertools: Iterator {
}
}

impl<T: ?Sized> Itertools for T where T: Iterator {}
impl<T> Itertools for T where T: Iterator + ?Sized {}

/// Return `true` if both iterables produce equal sequences
/// (elements pairwise equal and sequences of the same length),
Expand Down
8 changes: 4 additions & 4 deletions src/peeking_take_while.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ where
/// See [`.peeking_take_while()`](crate::Itertools::peeking_take_while)
/// for more information.
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
pub struct PeekingTakeWhile<'a, I: 'a, F>
pub struct PeekingTakeWhile<'a, I, F>
where
I: Iterator,
I: Iterator + 'a,
{
iter: &'a mut I,
f: F,
}

impl<'a, I: 'a, F> std::fmt::Debug for PeekingTakeWhile<'a, I, F>
impl<'a, I, F> std::fmt::Debug for PeekingTakeWhile<'a, I, F>
where
I: Iterator + std::fmt::Debug,
I: Iterator + std::fmt::Debug + 'a,
{
debug_fmt_fields!(PeekingTakeWhile, iter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tuple_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ where
/// information.
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[derive(Debug, Clone)]
pub struct CircularTupleWindows<I, T: Clone>
pub struct CircularTupleWindows<I, T>
where
I: Iterator<Item = T::Item> + Clone,
T: TupleCollect + Clone,
Expand Down
3 changes: 1 addition & 2 deletions src/ziptuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ pub struct Zip<T> {
/// [`izip!()`]: crate::izip
pub fn multizip<T, U>(t: U) -> Zip<T>
where
Zip<T>: From<U>,
Zip<T>: Iterator,
Zip<T>: From<U> + Iterator,
{
Zip::from(t)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ fn test_rciter() {
fn trait_pointers() {
struct ByRef<'r, I: ?Sized>(&'r mut I);

impl<'r, X, I: ?Sized> Iterator for ByRef<'r, I>
impl<'r, X, I> Iterator for ByRef<'r, I>
where
I: 'r + Iterator<Item = X>,
I: ?Sized + 'r + Iterator<Item = X>,
{
type Item = X;
fn next(&mut self) -> Option<Self::Item> {
Expand Down

0 comments on commit a638f83

Please sign in to comment.