Function chumsky::text::whitespace

source ·
pub fn whitespace<'a, C: Character + 'a, E: Error<C> + 'a>(
    
) -> Repeated<impl Parser<C, (), Error = E> + Copy + Clone + 'a>
Expand description

A parser that accepts (and ignores) any number of whitespace characters.

This parser is a Parser::Repeated and so methods such as at_least() can be called on it.

The output type of this parser is Vec<()>.

Examples

let whitespace = text::whitespace::<_, Simple<char>>();

// Any amount of whitespace is parsed...
assert_eq!(whitespace.parse("\t \n  \r "), Ok(vec![(), (), (), (), (), (), ()]));
// ...including none at all!
assert_eq!(whitespace.parse(""), Ok(vec![]));