diff --git a/src/adaptors/coalesce.rs b/src/adaptors/coalesce.rs index 21eaa016d..ad9df1192 100644 --- a/src/adaptors/coalesce.rs +++ b/src/adaptors/coalesce.rs @@ -17,9 +17,10 @@ where f: F, } -impl Clone for CoalesceBy +impl Clone for CoalesceBy where - I: Iterator, + I: Clone + Iterator, + F: Clone, C: CountItem, C::CItem: Clone, { diff --git a/src/free.rs b/src/free.rs index 5ce1b49b3..617a1977d 100644 --- a/src/free.rs +++ b/src/free.rs @@ -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 +pub fn cloned<'a, I, T>(iterable: I) -> iter::Cloned where I: IntoIterator, - T: Clone, + T: Clone + 'a, { iterable.into_iter().cloned() } diff --git a/src/groupbylazy.rs b/src/groupbylazy.rs index 3d1bfab5e..c318ec7b3 100644 --- a/src/groupbylazy.rs +++ b/src/groupbylazy.rs @@ -7,9 +7,9 @@ trait KeyFunction { fn call_mut(&mut self, arg: A) -> Self::Key; } -impl KeyFunction for F +impl KeyFunction for F where - F: FnMut(A) -> K, + F: FnMut(A) -> K + ?Sized, { type Key = K; #[inline] @@ -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, } @@ -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, index: usize, @@ -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, @@ -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, diff --git a/src/lib.rs b/src/lib.rs index c670e07b3..a571f49b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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); @@ -3962,7 +3961,7 @@ pub trait Itertools: Iterator { } } -impl Itertools for T where T: Iterator {} +impl Itertools for T where T: Iterator + ?Sized {} /// Return `true` if both iterables produce equal sequences /// (elements pairwise equal and sequences of the same length), diff --git a/src/peeking_take_while.rs b/src/peeking_take_while.rs index b08794a8d..b4852c1c9 100644 --- a/src/peeking_take_while.rs +++ b/src/peeking_take_while.rs @@ -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); } diff --git a/src/tuple_impl.rs b/src/tuple_impl.rs index ac04a1952..c0d556fc9 100644 --- a/src/tuple_impl.rs +++ b/src/tuple_impl.rs @@ -244,7 +244,7 @@ where /// information. #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[derive(Debug, Clone)] -pub struct CircularTupleWindows +pub struct CircularTupleWindows where I: Iterator + Clone, T: TupleCollect + Clone, diff --git a/src/ziptuple.rs b/src/ziptuple.rs index 82760ae8f..5ff0fad33 100644 --- a/src/ziptuple.rs +++ b/src/ziptuple.rs @@ -39,8 +39,7 @@ pub struct Zip { /// [`izip!()`]: crate::izip pub fn multizip(t: U) -> Zip where - Zip: From, - Zip: Iterator, + Zip: From + Iterator, { Zip::from(t) } diff --git a/tests/test_std.rs b/tests/test_std.rs index 063eca049..be163e98d 100644 --- a/tests/test_std.rs +++ b/tests/test_std.rs @@ -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, + I: ?Sized + 'r + Iterator, { type Item = X; fn next(&mut self) -> Option {