Skip to main content

oxilean_std/fin/
finiter_traits.rs

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