pub trait Peek {
fn peek(cursor: Cursor<'_>) -> bool;
fn display() -> &'static str;
fn peek2(cursor: Cursor<'_>) -> bool { ... }
}
Expand description
A trait for types which be used to “peek” to see if they’re the next token
in an input stream of Parser
.
Often when implementing Parse
you’ll need to query what the next token
in the stream is to figure out what to parse next. This Peek
trait
defines the set of types that can be tested whether they’re the next token
in the input stream.
Implementations of Peek
should only be present on types that consume
exactly one token (not zero, not more, exactly one). Types implementing
Peek
should also typically implement Parse
should also typically
implement Parse
.
See the documentation of Parser::peek
for example usage.