combine::parser::char

Function space

Source
pub fn space<I>() -> Space<I>
where I: Stream<Item = char>, I::Error: ParseError<I::Item, I::Range, I::Position>,
Expand description

Parse a single whitespace according to std::char::is_whitespace.

This includes space characters, tabs and newlines.

use combine::Parser;
use combine::parser::char::space;
assert_eq!(space().parse(" "), Ok((' ', "")));
assert_eq!(space().parse("  "), Ok((' ', " ")));
assert!(space().parse("!").is_err());
assert!(space().parse("").is_err());