Skip to main content

oxilean_std/prod/
pairiter_traits.rs

1//! # PairIter - Trait Implementations
2//!
3//! This module contains trait implementations for `PairIter`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Iterator`
8//! - `ExactSizeIterator`
9//!
10//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
11
12use super::types::PairIter;
13
14impl<T: Clone> Iterator for PairIter<T> {
15    type Item = T;
16    fn next(&mut self) -> Option<T> {
17        match self.idx {
18            0 => {
19                self.idx = 1;
20                Some(self.first.clone())
21            }
22            1 => {
23                self.idx = 2;
24                Some(self.second.clone())
25            }
26            _ => None,
27        }
28    }
29    fn size_hint(&self) -> (usize, Option<usize>) {
30        let remaining = 2usize.saturating_sub(self.idx);
31        (remaining, Some(remaining))
32    }
33}
34
35impl<T: Clone> ExactSizeIterator for PairIter<T> {}