Function parse_until_whitespace

Source
pub fn parse_until_whitespace(input: &str) -> IResult<&str, &str>
Expand description

Parse things until the first whitespace character (comments are whitespace). Parsing until end of input is also acceptable (end of input is whitespace)


assert_eq!(parse_until_whitespace("x  \n  foo"), Ok(("  \n  foo", "x")));
assert_eq!(parse_until_whitespace("foo bar"), Ok((" bar", "foo")));
assert_eq!(parse_until_whitespace("foo"), Ok(("", "foo")));
assert_eq!(parse_until_whitespace("foo# comment"), Ok(("# comment", "foo")));
assert_eq!(parse_until_whitespace("foo then a # comment"), Ok((" then a # comment", "foo")));
assert!(parse_until_whitespace("\n  foo").is_err());