Releases: weezy20/better_peekable
Releases · weezy20/better_peekable
v1.0.0
Release Notes - v1.0.0
Introduction
Better Peekable is a no_std compatible iterator adapter that provides multi-item lookahead functionality, designed for lexers, parsers, and other applications requiring efficient iterator peeking.
Features
- Multi-item lookahead with peek_n(n) method
- Standard peek() method equivalent to peek_n(0)
- Idempotent peeking operations that don't affect iterator state
- Full iterator trait support including DoubleEndedIterator and ExactSizeIterator
no_stdcompatibility withallocfeature- Efficient internal caching:
peek_n(n)will cachenitems into the internalVecDequeso subsequentpeek_n(m)wherem <= nare blazing fast lookups. So if you're going to do a lot of peeking, might as well peek in large numbers and then do short peeks.
API
- BetterPeekable trait extending all iterators
- BPeekable struct providing the lookahead functionality
- peek() - peek at next item
- peek_n(n) - peek n items ahead (0-indexed)
- init(iter) - convenience function for creating peekable iterators
Compatibility
Requires alloc feature for VecDeque support
Default features include alloc for standard usage
no_std environments are supported but would require the alloc feature to be enabled as VecDeque requires that for allocation.