diff --git a/src/impls/columns.rs b/src/impls/columns.rs index b678f4a..43366c7 100644 --- a/src/impls/columns.rs +++ b/src/impls/columns.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; use crate::impls::deduplicate::ConsecutiveOffsetPairs; use crate::impls::offsets::{OffsetContainer, OffsetOptimized}; -use crate::{CopyIter, IntoOwned}; +use crate::{IntoOwned, PushIter}; use crate::{OwnedRegion, Push, Region}; /// A region that can store a variable number of elements per row. @@ -388,7 +388,7 @@ where .iter() .zip(&mut self.inner) .map(|(value, region)| region.push(value)); - self.indices.push(CopyIter(iter)) + self.indices.push(PushIter(iter)) } } @@ -407,7 +407,7 @@ where .iter() .zip(&mut self.inner) .map(|(value, region)| region.push(value)); - self.indices.push(CopyIter(iter)) + self.indices.push(PushIter(iter)) } } @@ -426,7 +426,7 @@ where .into_iter() .zip(&mut self.inner) .map(|(value, region)| region.push(value)); - self.indices.push(CopyIter(iter)) + self.indices.push(PushIter(iter)) } } @@ -445,7 +445,7 @@ where .iter() .zip(&mut self.inner) .map(|(value, region)| region.push(value)); - self.indices.push(CopyIter(iter)) + self.indices.push(PushIter(iter)) } } @@ -464,7 +464,7 @@ where .into_iter() .zip(&mut self.inner) .map(|(value, region)| region.push(value)); - self.indices.push(CopyIter(iter)) + self.indices.push(PushIter(iter)) } } @@ -483,11 +483,11 @@ where .iter() .zip(&mut self.inner) .map(|(value, region)| region.push(value)); - self.indices.push(CopyIter(iter)) + self.indices.push(PushIter(iter)) } } -impl Push> for ColumnsRegion +impl Push> for ColumnsRegion where R: Region + Push, O: OffsetContainer, @@ -495,7 +495,7 @@ where I::IntoIter: ExactSizeIterator, { #[inline] - fn push(&mut self, item: CopyIter) -> as Region>::Index { + fn push(&mut self, item: PushIter) -> as Region>::Index { let iter = item.0.into_iter().enumerate().map(|(index, value)| { // Ensure all required regions exist. if self.inner.len() <= index { @@ -503,14 +503,14 @@ where } self.inner[index].push(value) }); - self.indices.push(CopyIter(iter)) + self.indices.push(PushIter(iter)) } } #[cfg(test)] mod tests { use crate::impls::deduplicate::{CollapseSequence, ConsecutiveOffsetPairs}; - use crate::{CopyIter, MirrorRegion, OwnedRegion, Push, Region, StringRegion}; + use crate::{MirrorRegion, OwnedRegion, Push, PushIter, Region, StringRegion}; use super::*; @@ -634,7 +634,7 @@ mod tests { let mut indices = Vec::with_capacity(data.len()); for row in &data { - let index = r.push(CopyIter(row.iter())); + let index = r.push(PushIter(row.iter())); indices.push(index); } @@ -716,7 +716,7 @@ mod tests { let mut r = ColumnsRegion::>::default(); for row in &data { - let _ = r.push(CopyIter(row.iter())); + let _ = r.push(PushIter(row.iter())); } let (mut siz1, mut cap1) = (0, 0); @@ -727,7 +727,7 @@ mod tests { let mut r2 = ColumnsRegion::merge_regions(std::iter::once(&r)); for row in &data { - let _ = r2.push(CopyIter(row.iter())); + let _ = r2.push(PushIter(row.iter())); } let (mut siz2, mut cap2) = (0, 0); diff --git a/src/impls/slice_copy.rs b/src/impls/slice_copy.rs index e20873f..209e0e0 100644 --- a/src/impls/slice_copy.rs +++ b/src/impls/slice_copy.rs @@ -6,7 +6,7 @@ use std::marker::PhantomData; use serde::{Deserialize, Serialize}; use crate::impls::storage::{PushStorage, Storage}; -use crate::{CopyIter, Push, Region, ReserveItems}; +use crate::{Push, PushIter, Region, ReserveItems}; /// A container for owned types. /// @@ -117,13 +117,13 @@ impl Push<[T; N]> for OwnedRegion where [T]: ToOwned, S: Storage - + for<'a> PushStorage> + + for<'a> PushStorage> + std::ops::Index, Output = [T]>, { #[inline] fn push(&mut self, item: [T; N]) -> as Region>::Index { let start = self.slices.len(); - self.slices.push_storage(CopyIter(item)); + self.slices.push_storage(PushIter(item)); (start, self.slices.len()) } } @@ -249,24 +249,24 @@ where } } -impl Push> for OwnedRegion +impl Push> for OwnedRegion where I: IntoIterator, ::IntoIter: ExactSizeIterator, T: Clone, S: Storage - + PushStorage> + + PushStorage> + std::ops::Index, Output = [T]>, { #[inline] - fn push(&mut self, item: CopyIter) -> as Region>::Index { + fn push(&mut self, item: PushIter) -> as Region>::Index { let start = self.slices.len(); self.slices.push_storage(item); (start, self.slices.len()) } } -impl ReserveItems> for OwnedRegion +impl ReserveItems> for OwnedRegion where [T]: ToOwned, S: Storage + std::ops::Index, Output = [T]>, @@ -275,7 +275,7 @@ where #[inline] fn reserve_items(&mut self, items: I) where - I: Iterator> + Clone, + I: Iterator> + Clone, { self.slices .reserve(items.flat_map(|i| i.0.into_iter()).count()); @@ -284,7 +284,7 @@ where #[cfg(test)] mod tests { - use crate::{CopyIter, Push, Region, ReserveItems}; + use crate::{Push, PushIter, Region, ReserveItems}; use super::*; @@ -318,8 +318,8 @@ mod tests { fn test_copy_iter() { let mut r = >::default(); let iter = [1; 4].into_iter(); - r.reserve_items(std::iter::once(CopyIter(iter.clone()))); - let index = r.push(CopyIter(iter)); + r.reserve_items(std::iter::once(PushIter(iter.clone()))); + let index = r.push(PushIter(iter)); assert_eq!([1, 1, 1, 1], r.index(index)); } } diff --git a/src/impls/storage.rs b/src/impls/storage.rs index f23c058..6e1b208 100644 --- a/src/impls/storage.rs +++ b/src/impls/storage.rs @@ -1,6 +1,6 @@ //! Storage abstractions to represent slices of data. -use crate::CopyIter; +use crate::PushIter; /// Behavior to allocate storage. /// @@ -105,9 +105,9 @@ impl PushStorage<&[T]> for Vec { } } -impl, T> PushStorage> for Vec { +impl, T> PushStorage> for Vec { #[inline] - fn push_storage(&mut self, item: CopyIter) { + fn push_storage(&mut self, item: PushIter) { self.extend(item.0); } } diff --git a/src/lib.rs b/src/lib.rs index d193712..b2e74c6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -422,13 +422,13 @@ impl Clone for FlatStack { } } -/// A type to wrap and copy iterators onto regions. +/// A type to wrap and push iterators into regions. /// /// This only exists to avoid blanket implementations that might conflict with more specific /// implementations offered by some regions. #[repr(transparent)] #[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd)] -pub struct CopyIter(pub I); +pub struct PushIter(pub I); #[cfg(test)] mod tests {