pub trait Input: Sized {
type Token: Token<Self>;
type Slice: Slice<Self>;
type Many: Length;
type Marker: Copy;
type Context: Show;
// Required methods
fn token(&mut self) -> Option<Self::Token>;
fn slice(&mut self, n: usize) -> Option<Self::Slice>;
fn peek<F>(&mut self, cond: F) -> bool
where F: FnMut(&Self::Token) -> bool;
fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool
where F: FnMut(&Self::Slice) -> bool;
fn eat<F>(&mut self, cond: F) -> Option<Self::Token>
where F: FnMut(&Self::Token) -> bool;
fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice>
where F: FnMut(&Self::Slice) -> bool;
fn take<F>(&mut self, cond: F) -> Self::Many
where F: FnMut(&Self::Token) -> bool;
fn skip<F>(&mut self, cond: F) -> usize
where F: FnMut(&Self::Token) -> bool;
fn has(&mut self, n: usize) -> bool;
fn mark(&mut self, info: &ParserInfo) -> Self::Marker;
fn context(&mut self, _mark: Self::Marker) -> Self::Context;
}
Required Associated Types§
type Token: Token<Self>
type Slice: Slice<Self>
type Many: Length
type Marker: Copy
type Context: Show
Required Methods§
Sourcefn token(&mut self) -> Option<Self::Token>
fn token(&mut self) -> Option<Self::Token>
Returns a copy of the current token, if there is one.
Sourcefn slice(&mut self, n: usize) -> Option<Self::Slice>
fn slice(&mut self, n: usize) -> Option<Self::Slice>
Returns a copy of the current slice of size n
, if there is one.
Sourcefn peek_slice<F>(&mut self, n: usize, cond: F) -> bool
fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool
Checks if the current slice of size n
(if any) fulfills cond
.
Sourcefn eat<F>(&mut self, cond: F) -> Option<Self::Token>
fn eat<F>(&mut self, cond: F) -> Option<Self::Token>
Checks if the current token fulfills cond
. If so, the token is
consumed and returned. Otherwise, returns None
.
Sourcefn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice>
fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice>
Checks if the current slice of size n
(if any) fulfills cond
. If so,
the slice is consumed and returned. Otherwise, returns None
.
Sourcefn take<F>(&mut self, cond: F) -> Self::Many
fn take<F>(&mut self, cond: F) -> Self::Many
Takes tokens while cond
returns true, collecting them into a
Self::Many
and returning it.
Sourcefn skip<F>(&mut self, cond: F) -> usize
fn skip<F>(&mut self, cond: F) -> usize
Skips tokens while cond
returns true. Returns the number of skipped
tokens.
Sourcefn mark(&mut self, info: &ParserInfo) -> Self::Marker
fn mark(&mut self, info: &ParserInfo) -> Self::Marker
Emits a marker that represents the current parse position.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<'a> Input for &'a str
impl<'a> Input for &'a str
Source§fn token(&mut self) -> Option<Self::Token>
fn token(&mut self) -> Option<Self::Token>
Returns a copy of the current token, if there is one.
Source§fn slice(&mut self, n: usize) -> Option<Self::Slice>
fn slice(&mut self, n: usize) -> Option<Self::Slice>
Returns a copy of the current slice of size n
, if there is one.
Source§fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool
fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool
Checks if the current slice of size n
(if any) fulfills cond
.
Source§fn eat<F>(&mut self, cond: F) -> Option<Self::Token>
fn eat<F>(&mut self, cond: F) -> Option<Self::Token>
Checks if the current token fulfills cond
. If so, the token is
consumed and returned. Otherwise, returns None
.
Source§fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice>
fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice>
Checks if the current slice of size n
(if any) fulfills cond
. If so,
the slice is consumed and returned. Otherwise, returns None
.
Source§fn take<F>(&mut self, cond: F) -> Self::Many
fn take<F>(&mut self, cond: F) -> Self::Many
Takes tokens while cond
returns true, collecting them into a
Self::Many
and returning it.
Source§fn skip<F>(&mut self, cond: F) -> usize
fn skip<F>(&mut self, cond: F) -> usize
Skips tokens while cond
returns true. Returns the number of skipped
tokens.