4 releases
0.2.0 | Jul 11, 2024 |
---|---|
0.1.2 | May 27, 2024 |
0.1.1 | May 27, 2024 |
0.1.0 | May 27, 2024 |
#716 in Rust patterns
13KB
161 lines
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
)