Skip to content

Commit

Permalink
Drop ExactSizeIterator requirement from Index::extend
Browse files Browse the repository at this point in the history
It's not used and apparently less reliable than an implementation might
assume.

Signed-off-by: Moritz Hoffmann <[email protected]>
  • Loading branch information
antiguru committed Jul 9, 2024
1 parent 7dc86fa commit b6cd3a4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/impls/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ where
R: Region + Push<T>,
O: IndexContainer<usize>,
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator,
{
#[inline]
fn push(&mut self, item: PushIter<I>) -> <ColumnsRegion<R, O> as Region>::Index {
Expand Down
16 changes: 3 additions & 13 deletions src/impls/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ pub trait IndexContainer<T>: Storage<T> {
/// Accepts a newly pushed element.
fn push(&mut self, item: T);

/// Extend from iterator. Must be [`ExactSizeIterator`] to efficiently
/// pre-allocate.
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
where
I::IntoIter: ExactSizeIterator;
/// Extend from iterator.
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I);

/// Returns an iterator over the elements.
fn iter(&self) -> Self::Iter<'_>;
Expand Down Expand Up @@ -320,8 +317,6 @@ where

#[inline]
fn extend<I: IntoIterator<Item = usize>>(&mut self, iter: I)
where
I::IntoIter: ExactSizeIterator,
{
for item in iter {
self.push(item);
Expand Down Expand Up @@ -436,8 +431,6 @@ where
}

fn extend<I: IntoIterator<Item = usize>>(&mut self, iter: I)
where
I::IntoIter: ExactSizeIterator,
{
for item in iter {
self.push(item);
Expand Down Expand Up @@ -483,10 +476,7 @@ impl<T: Copy> IndexContainer<T> for Vec<T> {
self.push(item);
}

fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
where
I::IntoIter: ExactSizeIterator,
{
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
Extend::extend(self, iter);
}

Expand Down
1 change: 0 additions & 1 deletion src/impls/slice_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ where
impl<T, S, I> Push<PushIter<I>> for OwnedRegion<T, S>
where
I: IntoIterator<Item = T>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
T: Clone,
S: Storage<T>
+ PushStorage<PushIter<I>>
Expand Down

0 comments on commit b6cd3a4

Please sign in to comment.