Function winnow::character::multispace1
source · pub fn multispace1<I, E: ParseError<I>>(
input: I
) -> IResult<I, <I as Stream>::Slice, E>where
I: StreamIsPartial + Stream,
<I as Stream>::Token: AsChar + Copy,
Expand description
Recognizes one or more spaces, tabs, carriage returns and line feeds.
Complete version: will return an error if there’s not enough input data, or the whole input if no terminating token is found (a non space character).
Partial version: Will return Err(winnow::error::ErrMode::Incomplete(_))
if there’s not enough input data,
or if no terminating token is found (a non space character).
Example
fn parser(input: &str) -> IResult<&str, &str> {
multispace1(input)
}
assert_eq!(parser(" \t\n\r21c"), Ok(("21c", " \t\n\r")));
assert_eq!(parser("H2"), Err(ErrMode::Backtrack(Error::new("H2", ErrorKind::Slice))));
assert_eq!(parser(""), Err(ErrMode::Backtrack(Error::new("", ErrorKind::Slice))));
assert_eq!(multispace1::<_, Error<_>>(Partial::new(" \t\n\r21c")), Ok((Partial::new("21c"), " \t\n\r")));
assert_eq!(multispace1::<_, Error<_>>(Partial::new("H2")), Err(ErrMode::Backtrack(Error::new(Partial::new("H2"), ErrorKind::Slice))));
assert_eq!(multispace1::<_, Error<_>>(Partial::new("")), Err(ErrMode::Incomplete(Needed::new(1))));