BoxDynLexerParseFn

Type Alias BoxDynLexerParseFn 

Source
pub type BoxDynLexerParseFn<'a, L> = Box<dyn for<'call> Fn(&'call L, <L as Lexer>::State, char) -> LexerParseResult<<L as Lexer>::State, <L as Lexer>::Token, <L as Lexer>::Error> + 'a>;
Expand description

The type of a parse function, when Boxed as a dyn trait

This type can be used in arrays/slices to allow a Lexer to run through a list of possible token parsers such as:

      let parsers = [
           Box::new(parse_char_fn) as BoxDynLexerParseFn<OurLexer>
           Box::new(parse_value_fn),
           Box::new(parse_whitespace_fn),
       ];

Note that the use of ‘as Box…’ is required, as without it type inference will kick in on the Box::new() to infer parse_char_fn as a precise type, whereas the more generic dyn Fn is what is required.

Aliased Type§

pub struct BoxDynLexerParseFn<'a, L>(/* private fields */);