peeking-iter

Crates.iopeeking-iter
lib.rspeeking-iter
version0.2.0
sourcesrc
created_at2024-05-27 09:13:22.69855
updated_at2024-07-11 16:10:33.194817
descriptionAn iterator adapter that allows infinitely-deep peeking
homepage
repositoryhttps://github.com/Froloket64/peeking-iter
max_upload_size
id1253210
size18,472
(Froloket64)

documentation

README

peeking-iter

A fast and simple iterator adapter that allows peeking with any depth:

use peeking_iter::PeekingIter

fn main() {
    let it = PeekingIter::new(0..=2);

    assert_eq!(it.next(), Some(0));
    assert_eq!(it.peek(), Some(1));
    assert_eq!(it.peek(), Some(2));
    assert_eq!(it.next(), Some(1));
    assert_eq!(it.peek(), Some(2));
    assert_eq!(it.peek(), None);
}

Why?

  • ~1.5x faster than itertools' MultiPeek
  • Has useful methods initially designed with lexing and parsing in mind (see Parser)
Commit count: 14

cargo fmt