diff --git a/src/lib.rs b/src/lib.rs index d193712..c5b9881 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -186,10 +186,9 @@ impl Default for FlatStack { impl::Index>> Debug for FlatStack where for<'a> R::ReadItem<'a>: Debug, - for<'a> &'a S: IntoIterator, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_list().entries(self.iter()).finish() + f.debug_list().entries(self.into_iter()).finish() } } @@ -294,10 +293,7 @@ where { /// Iterate the items in this stack. #[inline] - pub fn iter<'a>(&'a self) -> Iter<'a, R, <&'a S as IntoIterator>::IntoIter> - where - &'a S: IntoIterator, - { + pub fn iter<'a>(&'a self) -> Iter<'a, R, S::Iter<'a>> { self.into_iter() } } @@ -331,16 +327,13 @@ where } } -impl<'a, R: Region, S: OffsetContainer<::Index>> IntoIterator for &'a FlatStack -where - &'a S: IntoIterator::Index>, -{ +impl<'a, R: Region, S: OffsetContainer<::Index>> IntoIterator for &'a FlatStack { type Item = R::ReadItem<'a>; - type IntoIter = Iter<'a, R, <&'a S as IntoIterator>::IntoIter>; + type IntoIter = Iter<'a, R, S::Iter<'a>>; fn into_iter(self) -> Self::IntoIter { Iter { - inner: self.indices.into_iter(), + inner: self.indices.iter(), region: &self.region, } } @@ -351,7 +344,6 @@ where pub struct Iter<'a, R, S> where R: Region, - S: Iterator::Index>, { /// Iterator over indices. inner: S, @@ -362,12 +354,12 @@ where impl<'a, R, S> Iterator for Iter<'a, R, S> where R: Region, - S: Iterator::Index>, + S: Iterator::Index>, { type Item = R::ReadItem<'a>; fn next(&mut self) -> Option { - self.inner.next().map(|idx| self.region.index(*idx)) + self.inner.next().map(|idx| self.region.index(idx)) } fn size_hint(&self) -> (usize, Option) { @@ -378,14 +370,14 @@ where impl<'a, R, S> ExactSizeIterator for Iter<'a, R, S> where R: Region, - S: ExactSizeIterator::Index>, + S: ExactSizeIterator::Index>, { } impl<'a, R, S> Clone for Iter<'a, R, S> where R: Region, - S: Iterator::Index> + Clone, + S: Iterator::Index> + Clone, { fn clone(&self) -> Self { Self {