pub(crate) struct ZipExact<A, B> {
a: A,
b: B,
}
impl<A: Iterator, B: Iterator> Iterator for ZipExact<A, B> {
type Item = (A::Item, B::Item);
#[inline]
fn next(&mut self) -> Option<Self::Item> {
let a = self.a.next()?;
let b = self
.b
.next()
.unwrap_or_else(|| unsafe { crate::debug_unreachable() });
Some((a, b))
}
}
#[inline]
pub(crate) unsafe fn zip_exact<A: IntoIterator, B: IntoIterator>(
a: A,
b: B,
) -> ZipExact<A::IntoIter, B::IntoIter>
where
A::IntoIter: ExactSizeIterator,
B::IntoIter: ExactSizeIterator,
{
let a = a.into_iter();
let b = b.into_iter();
debug_assert_eq!(a.len(), b.len());
ZipExact { a, b }
}