Loading RustViz Engine...
Build a custom StepBy<I> iterator struct adapting any underlying iterator.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
pub struct StepBy<I> {
iter: I,
step: usize,
}
impl<I: Iterator> Iterator for StepBy<I> {
type Item = I::Item;
fn next(&mut self) -> Option<Self::Item> {
let item = self.iter.next()?;
for _ in 1..self.step {
self.iter.next();
}
Some(item)
}
}