From 1426e5b7e3bee4ddc569e4cce5abfd59523b9ee8 Mon Sep 17 00:00:00 2001 From: John Turner Date: Sat, 25 Oct 2025 17:29:09 -0400 Subject: impl Eof parser --- src/lib.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index d0b9cb3..930acfe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -911,6 +911,33 @@ where } } +struct Eof; + +impl Parser for Eof +where + I: Input, +{ + type Output = (); + + fn run>( + &self, + it: InputIter, + ) -> ParserResult { + if it.is_finished() { + Ok((it, OM::bind(|| ()))) + } else { + Err(EM::bind(|| it)) + } + } +} + +pub fn eof() -> impl Parser +where + I: Input, +{ + Eof +} + pub fn alpha() -> impl Parser where I: Input, -- cgit v1.2.3