oni_comb_parser/text/
eof.rs1use crate::error::ParseError;
2use crate::fail::{Fail, PResult};
3use crate::input::Input;
4use crate::parser::Parser;
5use crate::str_input::StrInput;
6
7pub struct Eof;
8
9pub fn eof() -> Eof {
10 Eof
11}
12
13impl Parser<StrInput<'_>> for Eof {
14 type Error = ParseError;
15 type Output = ();
16
17 #[inline]
18 fn parse_next(&mut self, input: &mut StrInput<'_>) -> PResult<(), ParseError> {
19 if input.is_eof() {
20 Ok(())
21 } else {
22 Err(Fail::Backtrack(ParseError::expected_eof(input.offset())))
23 }
24 }
25}