Trait relex::TokenKind[][src]

pub trait TokenKind: Clone + PartialEq {
    fn unrecognized() -> Self;
fn eof() -> Self; fn is_unrecognized(&self) -> bool { ... }
fn is_eof(&self) -> bool { ... } }
Expand description

You must implement this trait for your own custom TokenKind’s For example:

use relex::TokenKind;

#[derive(Debug, Clone, PartialEq)]
enum MyToken {
  Whitespace,
  ID,
  Eof,
  Unrecognized,
}
impl TokenKind for MyToken {
  fn eof() -> Self { MyToken::Eof }
  fn unrecognized() -> Self { MyToken::Unrecognized }
}

Required methods

fn unrecognized() -> Self[src]

Constructs a TokenKind denoting that the token of interest is “unrecognized” (i.e., unmatched by any given regex)

fn eof() -> Self[src]

Constructs a TokenKind denoting that the token of interest is at the end of the input

Provided methods

fn is_unrecognized(&self) -> bool[src]

fn is_eof(&self) -> bool[src]

Implementors