Skip to main content

oni_comb_parser/
parser.rs

1#[cfg(feature = "alloc")]
2use alloc::boxed::Box;
3
4use crate::fail::PResult;
5use crate::input::Input;
6
7pub trait Parser<I: Input> {
8  type Output;
9  type Error;
10
11  fn parse_next(&mut self, input: &mut I) -> PResult<Self::Output, Self::Error>;
12}
13
14#[cfg(feature = "alloc")]
15impl<I: Input, P: Parser<I> + ?Sized> Parser<I> for Box<P> {
16  type Error = P::Error;
17  type Output = P::Output;
18
19  #[inline]
20  fn parse_next(&mut self, input: &mut I) -> PResult<Self::Output, Self::Error> {
21    (**self).parse_next(input)
22  }
23}