Overview
This crate defines a buffer with a cursor, plus some useful operations on the buffer.
Caveats
- The parameterized type of
PeekableBuffermust implementClone - If your
PeekableBuffercontains close tousize.MAXelements, the indexing operations will probably fail
Quick Start
In Cargo.toml
[dependencies]
peekable_buffer = "1.0.0"
Create a PeekableBuffer<T> using
let v = vec!;
let mut stream = new;
assert!;
assert_eq!;
assert_eq!;
stream.advance;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
stream.shift;
assert_eq!;
assert_eq!;
assert!;
assert_eq!;
Available Operations
These are taken directly from the source.
/// Creates a `Stream` object that owns all elements of `&[T]` via cloning.
Error Handling
Most of the APIs have defined behavior for the more common "strange input"
cases, so there's no error handling to be found in this library. All of the
libraries that return a reference to an element in the buffer is returned as
an Option<&T>.
The exception is the function slice_between that panicks in the case where
from_inc > to_exc. Do LBYL before passing the parameters to this particular
function.