[][src]Function chonk::parsers::matching::space

pub fn space<'a, Rng, Msg>(range: Rng) -> impl Parser<'a, &'a str, Msg> where
    Rng: RangeBounds<usize> + Clone

Match a number of whitespace characters, from a minimum to a maximum.

fn parser_a<'a>() -> impl Parser<'a, &'a str, ()> {
    move |ctx| {
        take(1.., is(whitespace)).parse(ctx)
    }
}

fn parser_b<'a>() -> impl Parser<'a, &'a str, ()> {
    move |ctx| {
        space(1..).parse(ctx)
    }
}

assert_eq!(
    parser_a().parse(" foobar"),
    parser_b().parse(" foobar")
);