umgap/utils.rs
1//! Some utils.
2
3/// Interleaving iterator.
4pub struct Zip<E, I: Iterator<Item = E>> {
5 parts: Vec<I>,
6}
7
8impl<E, I: Iterator<Item = E>> Zip<E, I> {
9 /// Constructor for Zip.
10 pub fn new(parts: Vec<I>) -> Self {
11 Zip { parts }
12 }
13}
14
15impl<E, I: Iterator<Item = E>> Iterator for Zip<E, I> {
16 type Item = Vec<E>;
17
18 fn next(&mut self) -> Option<Self::Item> {
19 self.parts.iter_mut().map(|part| part.next()).collect()
20 }
21}