diff --git a/src/impls/offsets.rs b/src/impls/offsets.rs index 3f2a79d..c968c24 100644 --- a/src/impls/offsets.rs +++ b/src/impls/offsets.rs @@ -8,7 +8,7 @@ use crate::impls::storage::Storage; /// A container to store offsets. pub trait OffsetContainer: Storage { /// Iterator over the elements. - type Iter<'a>: Iterator + type Iter<'a>: Iterator + Clone where Self: 'a; @@ -152,6 +152,7 @@ impl OffsetStride { } /// An iterator over the elements of an [`OffsetStride`]. +#[derive(Clone, Copy)] pub struct OffsetStrideIter { strided: OffsetStride, index: usize, @@ -305,7 +306,7 @@ where S: OffsetContainer, L: OffsetContainer, { - type Iter<'a> = OffsetListIter<'a, S, L> where Self: 'a; + type Iter<'a> = OffsetListIter, L::Iter<'a>> where Self: 'a; #[inline] fn index(&self, index: usize) -> usize { @@ -337,19 +338,16 @@ where } /// An iterator over the elements of an [`OffsetList`]. -pub struct OffsetListIter<'a, S, L> -where - S: OffsetContainer + 'a, - L: OffsetContainer + 'a, -{ - smol: S::Iter<'a>, - chonk: L::Iter<'a>, +#[derive(Clone, Copy)] +pub struct OffsetListIter { + smol: S, + chonk: L, } -impl<'a, S, L> Iterator for OffsetListIter<'a, S, L> +impl Iterator for OffsetListIter where - S: OffsetContainer + 'a, - L: OffsetContainer + 'a, + S: Iterator, + L: Iterator, { type Item = usize; @@ -366,11 +364,7 @@ where /// a regular offset list. #[derive(Eq, PartialEq, Default, Debug, Clone)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct OffsetOptimized, L = Vec> -where - S: OffsetContainer, - L: OffsetContainer, -{ +pub struct OffsetOptimized, L = Vec> { strided: OffsetStride, spilled: OffsetList, } @@ -420,7 +414,7 @@ where S: OffsetContainer, L: OffsetContainer, { - type Iter<'a> = OffsetOptimizedIter<'a, S , L> where Self: 'a; + type Iter<'a> = OffsetOptimizedIter, L::Iter<'a>> where Self: 'a; fn index(&self, index: usize) -> usize { if index < self.strided.len() { @@ -459,19 +453,16 @@ where } /// An iterator over the elements of an [`OffsetOptimized`]. -pub struct OffsetOptimizedIter<'a, S, L> -where - S: OffsetContainer + 'a, - L: OffsetContainer + 'a, -{ +#[derive(Clone, Copy)] +pub struct OffsetOptimizedIter { strided: OffsetStrideIter, - spilled: as OffsetContainer>::Iter<'a>, + spilled: OffsetListIter, } -impl<'a, S, L> Iterator for OffsetOptimizedIter<'a, S, L> +impl Iterator for OffsetOptimizedIter where - S: OffsetContainer + 'a, - L: OffsetContainer + 'a, + S: Iterator, + L: Iterator, { type Item = usize;