From da67ed8cd082a0550b95a9bb0b77a8870579cb40 Mon Sep 17 00:00:00 2001 From: John Turner Date: Fri, 24 Oct 2025 00:42:18 -0400 Subject: impl Ignore combinator --- src/lib.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 686ce6f..4b01b57 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -180,6 +180,10 @@ pub trait Parser: Sized { checker, } } + + fn ignore(self) -> impl Parser { + Ignore { parser: self } + } } impl Parser for F @@ -849,6 +853,28 @@ where } } +struct Ignore

{ + parser: P, +} + +impl Parser for Ignore

+where + I: Input, + P: Parser, +{ + type Output = (); + + fn run>( + &mut self, + it: InputIter, + ) -> ParserResult { + match self.parser.check(it) { + Ok((rest, _)) => Ok((rest, OM::bind(|| ()))), + Err(rest) => Err(EM::bind(|| rest)), + } + } +} + pub fn alpha() -> impl Parser where I: Input, -- cgit v1.2.3