use std::marker::PhantomData;
use crate::prelude::{Error, PInput, PSuccess, Parser, ParserCore};
#[derive(Clone)]
pub struct PIgnoreThen<P1, P2, OI> {
ignore: P1,
then: P2,
_marker: PhantomData<OI>,
}
pub fn pignore_then<P1, P2, OI>(ignore: P1, then: P2) -> PIgnoreThen<P1, P2, OI> {
PIgnoreThen {
ignore,
then,
_marker: PhantomData,
}
}
impl<'a, K, O, P1, P2, OI> ParserCore<'a, K, O> for PIgnoreThen<P1, P2, OI>
where
K: PartialEq + Clone + 'a,
O: Clone + 'a,
OI: Clone + 'a,
P1: Parser<'a, K, OI>,
P2: Parser<'a, K, O>,
{
fn parse(&self, i: PInput<'a, K>) -> Result<PSuccess<'a, K, O>, Error<'a, K>> {
let PSuccess { val: _, rest } = self.ignore.parse(i)?;
self.then.parse(rest)
}
}
impl<'a, K, O, P1, P2, OI> Parser<'a, K, O> for PIgnoreThen<P1, P2, OI>
where
K: PartialEq + Clone + 'a,
O: Clone + 'a,
OI: Clone + 'a,
P1: Parser<'a, K, OI>,
P2: Parser<'a, K, O>,
{
}