Trait Recognizable

Source
pub trait Recognizable<'a, T, V>: MatchSize {
    // Required method
    fn recognize(self, scanner: &mut Scanner<'a, T>) -> ParseResult<Option<V>>;
}
Expand description

A trait that defines how to recognize an object.

§Type Parameters

  • V - The type of the object to recognize
  • T - The type of the data to scan
  • 'a - The lifetime of the data to scan

Required Methods§

Source

fn recognize(self, scanner: &mut Scanner<'a, T>) -> ParseResult<Option<V>>

Try to recognize the object for the given scanner.

§Type Parameters

V - The type of the object to recognize

§Arguments
  • scanner - The scanner to recognize the object for.
§Returns
  • Ok(Some(V)) if the object was recognized,
  • Ok(None) if the object was not recognized,
  • Err(ParseError) if an error occurred

Implementors§

Source§

impl<'a, T, M: Match<T> + MatchSize> Recognizable<'a, T, &'a [T]> for M

Recognize an object for the given scanner. Return a slice of the recognized object.