Skip to content

Commit

Permalink
Add missing FusedIterator impls
Browse files Browse the repository at this point in the history
  • Loading branch information
rossmacarthur committed Dec 7, 2023
1 parent 0e9855a commit efe54e9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/adaptors/array_chunks.rs
@@ -1,3 +1,5 @@
use core::iter::FusedIterator;

/// An extension trait that provides the [`array_chunks`] method for iterators.
///
/// Note: the method provided here has a nightly API:
Expand Down Expand Up @@ -129,3 +131,5 @@ where
self.iter.len() / N
}
}

impl<I, const N: usize> FusedIterator for ArrayChunks<I, N> where I: FusedIterator {}
9 changes: 9 additions & 0 deletions src/adaptors/array_windows.rs
@@ -1,3 +1,5 @@
use core::iter::FusedIterator;

/// An extension trait that provides the [`array_windows`] method for iterators.
///
/// [`array_windows`]: IterArrayWindows::array_windows
Expand Down Expand Up @@ -120,3 +122,10 @@ where
self.iter.count().saturating_sub(N - 1)
}
}

impl<I, const N: usize> FusedIterator for ArrayWindows<I, N>
where
I: FusedIterator + Clone,
I::Item: Clone,
{
}
10 changes: 10 additions & 0 deletions src/adaptors/cartesian_product.rs
@@ -1,3 +1,5 @@
use core::iter::FusedIterator;

/// An extension trait that provides the [`cartesian_product`] method for
/// iterators.
///
Expand Down Expand Up @@ -85,6 +87,14 @@ where
}
}

impl<I, J> FusedIterator for CartesianProduct<I, J>
where
I: FusedIterator,
J: FusedIterator + Clone,
I::Item: Clone,
{
}

////////////////////////////////////////////////////////////////////////////////
// Macro
////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit efe54e9

Please sign in to comment.