Trait nommy::Buffer [−][src]
Buffer
is an extension to an Iterator
,
with the ability to create a cursor over the iterator,
which can infinitely read from the iterator, preserving the buffer's position
use nommy::{Buffer, IntoBuf}; let mut buffer = (0..).into_buf(); let mut cursor1 = buffer.cursor(); // cursors act exactly like an iterator assert_eq!(cursor1.next(), Some(0)); assert_eq!(cursor1.next(), Some(1)); // cursors can be made from other cursors let mut cursor2 = cursor1.cursor(); assert_eq!(cursor2.next(), Some(2)); assert_eq!(cursor2.next(), Some(3)); // child cursors do not move the parent's iterator position assert_eq!(cursor1.next(), Some(2)); // Same with the original buffer assert_eq!(buffer.next(), Some(0));
Required methods
fn fast_forward(&mut self, n: usize)
[src]
Skip the iterator ahead by n steps
fn peek_ahead(&mut self, i: usize) -> Option<T>
[src]
Peek ahead by i spaces
Provided methods
fn cursor(&mut self) -> Cursor<'_, T, Self>ⓘ
[src]
Create a new cursor from this buffer any reads the cursor makes will not affect the next values the buffer will read
Implementors
impl<'a, T, B: Buffer<T>> Buffer<T> for Cursor<'a, T, B>
[src]
fn fast_forward(&mut self, n: usize)
[src]
fn peek_ahead(&mut self, i: usize) -> Option<T>
[src]
impl<I: Iterator> Buffer<<I as Iterator>::Item> for Buf<I> where
I::Item: Clone,
[src]
I::Item: Clone,