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.

Required Methods

Tests to see whether this token is the first token within the Cursor specified.

Returns true if Parse for this type is highly likely to succeed failing no other error conditions happening (like an integer literal being too big).

Returns a human-readable name of this token to display when generating errors about this token missing.

Provided Methods

The same as peek, except it checks the token immediately following the current token.

Implementations on Foreign Types

Implementors

source

impl Peek for post_return