Trait chumsky::text::TextParser

source ·
pub trait TextParser<I: Character, O>: Parser<I, O> {
    // Provided method
    fn padded(self) -> Padded<Self>
       where Self: Sized { ... }
}
Expand description

A trait containing text-specific functionality that extends the Parser trait.

Provided Methods§

source

fn padded(self) -> Padded<Self>where Self: Sized,

Parse a pattern, ignoring any amount of whitespace both before and after the pattern.

The output type of this parser is O, the same as the original parser.

Examples
let ident = text::ident::<_, Simple<char>>().padded();

// A pattern with no whitespace surrounding it is accepted
assert_eq!(ident.parse("hello"), Ok("hello".to_string()));
// A pattern with arbitrary whitespace surrounding it is also accepted
assert_eq!(ident.parse(" \t \n  \t   world  \t  "), Ok("world".to_string()));

Implementors§

source§

impl<I: Character, O, P: Parser<I, O>> TextParser<I, O> for P