1 unstable release
0.1.0 | Oct 15, 2023 |
---|
#1502 in Rust patterns
2.5MB
277 lines
fullypeek
Peek forward in an iterator as far as you'd like, memory allowing!
let mut peekable = vec![1, 2, 3].into_iter().fully_peekable();
assert_eq!(peekable.peek(), Some(&1));
assert_eq!(peekable.peek_many(2), vec!(Some(&1), Some(&2)));
peekable.next();
assert_eq!(peekable.peek(), Some(&2));
assert_eq!(peekable.peek_many(2), vec!(Some(&2), Some(&3)));
peekable.next();
assert_eq!(peekable.peek(), Some(&3));
assert_eq!(peekable.peek_many(2), vec!(Some(&3), None));
lib.rs
:
This crate contains an iterator which allows you to fully peek forward any number of elements.