orx_iterable/transformations/
zipped.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::Iterable;

/// An iterable created by zipping two iterables.
pub struct Zipped<I1, I2>
where
    I1: Iterable,
    I2: Iterable,
{
    pub(crate) it1: I1,
    pub(crate) it2: I2,
}

impl<I1, I2> Iterable for Zipped<I1, I2>
where
    I1: Iterable,
    I2: Iterable,
{
    type Item = (I1::Item, I2::Item);

    type Iter = core::iter::Zip<I1::Iter, I2::Iter>;

    fn iter(&self) -> Self::Iter {
        self.it1.iter().zip(self.it2.iter())
    }
}