Struct combine::state::State
[−]
[src]
pub struct State<I, X> { pub input: I, pub positioner: X, }
The State<I>
struct maintains the current position in the stream I
using
the Positioner
trait to track the position.
let result = token(b'9') .message("Not a nine") .parse(State::new(&b"8"[..])); assert_eq!(result, Err(ParseError { position: 0, errors: vec![ Error::Unexpected(b'8'.into()), Error::Expected(b'9'.into()), Error::Message("Not a nine".into()) ] }));
Fields
input: I
The input stream used when items are requested
positioner: X
The positioner used to update the current position
Methods
impl<I, X> State<I, X> where
I: StreamOnce,
X: Positioner<I::Item>,
[src]
I: StreamOnce,
X: Positioner<I::Item>,
fn with_positioner(input: I, positioner: X) -> State<I, X>
Creates a new State<I, X>
from an input stream and a positioner.
impl<I> State<I, I::Positioner> where
I: StreamOnce + DefaultPositioned,
I::Positioner: Positioner<I::Item>,
[src]
I: StreamOnce + DefaultPositioned,
I::Positioner: Positioner<I::Item>,
fn new(input: I) -> State<I, I::Positioner>
Creates a new State<I, X>
from an input stream and its default positioner.
Trait Implementations
impl<I: Clone, X: Clone> Clone for State<I, X>
[src]
fn clone(&self) -> State<I, X>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<I: Debug, X: Debug> Debug for State<I, X>
[src]
impl<I: PartialEq, X: PartialEq> PartialEq for State<I, X>
[src]
fn eq(&self, __arg_0: &State<I, X>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &State<I, X>) -> bool
This method tests for !=
.
impl<I, X> Positioned for State<I, X> where
I: StreamOnce,
X: Positioner<I::Item>,
[src]
I: StreamOnce,
X: Positioner<I::Item>,
type Position = X::Position
Type which represents the position in a stream. Ord
is required to allow parsers to determine which of two positions are further ahead. Read more
fn position(&self) -> Self::Position
Returns the current position of the stream.
impl<I, X> StreamOnce for State<I, X> where
I: StreamOnce,
X: Positioner<I::Item>,
[src]
I: StreamOnce,
X: Positioner<I::Item>,
type Item = I::Item
The type of items which is yielded from this stream.
type Range = I::Range
The type of a range of items yielded from this stream. Types which do not a have a way of yielding ranges of items should just use the Self::Item
for this type. Read more
fn uncons(&mut self) -> Result<I::Item, Error<I::Item, I::Range>>
Takes a stream and removes its first item, yielding the item and the rest of the elements. Returns Err
if no element could be retrieved. Read more
impl<I, X> RangeStream for State<I, X> where
I: RangeStream,
X: Clone + RangePositioner<I::Item, I::Range>,
I::Position: Clone + Ord,
[src]
I: RangeStream,
X: Clone + RangePositioner<I::Item, I::Range>,
I::Position: Clone + Ord,
fn uncons_range(
&mut self,
size: usize
) -> Result<I::Range, Error<I::Item, I::Range>>
&mut self,
size: usize
) -> Result<I::Range, Error<I::Item, I::Range>>
Takes size
elements from the stream. Fails if the length of the stream is less than size
. Read more
fn uncons_while<F>(
&mut self,
predicate: F
) -> Result<I::Range, Error<I::Item, I::Range>> where
F: FnMut(I::Item) -> bool,
&mut self,
predicate: F
) -> Result<I::Range, Error<I::Item, I::Range>> where
F: FnMut(I::Item) -> bool,
Takes items from stream, testing each one with predicate
. returns the range of items which passed predicate
. Read more
fn distance(&self, end: &Self) -> usize
Returns the distance between self
and end
. The returned usize
must be so that Read more
impl<I, X> FullRangeStream for State<I, X> where
I: FullRangeStream,
I::Position: Clone + Ord,
X: Clone + RangePositioner<I::Item, I::Range>,
[src]
I: FullRangeStream,
I::Position: Clone + Ord,
X: Clone + RangePositioner<I::Item, I::Range>,