use crate::characters::*;
use crate::combinators::*;
use crate::types::*;
use std::ops::RangeBounds;
#[inline]
pub fn space<'a, Rng>(range: Rng) -> impl Parser<'a, &'a str>
where
Rng: RangeBounds<usize> + Clone,
{
move |ctx| take(range.clone(), is(whitespace)).parse(ctx)
}
#[inline]
pub fn trim<'a, Par, Res>(mut parser: Par) -> impl Parser<'a, Res>
where
Par: Parser<'a, Res>,
{
move |ctx| {
let ctx = space(0..).parse(ctx).unwrap();
match parser.parse(ctx)? {
(ctx, res) => match space(0..).parse(ctx).unwrap() {
(ctx, _) => Ok(ctx.with_data(res)),
},
}
}
}