Trait chomp::types::Buffer
[−]
[src]
pub trait Buffer: PartialEq<Self> { type Token: Copy + PartialEq; fn fold<B, F>(self, _: B, _: F) -> B
where
F: FnMut(B, Self::Token) -> B; fn iterate<F>(&self, _: F)
where
F: FnMut(Self::Token); fn len(&self) -> usize; fn to_vec(&self) -> Vec<Self::Token>; fn into_vec(self) -> Vec<Self::Token>; fn is_empty(&self) -> bool { ... } }
The buffers yielded parsers consuming a sequence of the input.
This could either be an owned type or a slice reference depending on the Input
implementation.
Associated Types
Required Methods
fn fold<B, F>(self, _: B, _: F) -> B where
F: FnMut(B, Self::Token) -> B,
F: FnMut(B, Self::Token) -> B,
Applies a function in order on all tokens present in the buffer carrying an accumulator
value B
between invocations. The buffer is consumed as part of the folding and the last
value of the accumulator is returned.
fn iterate<F>(&self, _: F) where
F: FnMut(Self::Token),
F: FnMut(Self::Token),
Runs the supplied function on a borrow of each token present in the buffer. Invoked in order and once per token.
fn len(&self) -> usize
The number of tokens present in this buffer.
fn to_vec(&self) -> Vec<Self::Token>
Copies all the tokens in this buffer to a new Vec
.
fn into_vec(self) -> Vec<Self::Token>
Consumes self to create an owned vector of tokens.
Will allocate if the implementation borrows storage or does not use an owned type
compatible with Vec
internally.