Parser that attaches an error of the given [BgeoParserErrorKind] if the inner parser fails
(
kind: BgeoParserErrorKind,
mut f: F,
)
| 844 | |
| 845 | /// Parser that attaches an error of the given [BgeoParserErrorKind] if the inner parser fails |
| 846 | pub fn bgeo_error<I: Clone, F, O>( |
| 847 | kind: BgeoParserErrorKind, |
| 848 | mut f: F, |
| 849 | ) -> impl FnMut(I) -> IResult<I, O, BgeoParserError<I>> |
| 850 | where |
| 851 | F: Parser<I, Output = O, Error = BgeoParserError<I>>, |
| 852 | { |
| 853 | use nom::Err; |
| 854 | move |i: I| match f.parse(i.clone()) { |
| 855 | Ok(o) => Ok(o), |
| 856 | Err(Err::Incomplete(i)) => Err(Err::Incomplete(i)), |
| 857 | Err(Err::Error(e)) => Err(Err::Error(e.with_append(i, kind.clone()))), |
| 858 | Err(Err::Failure(e)) => Err(Err::Failure(e.with_append(i, kind.clone()))), |
| 859 | } |
| 860 | } |
| 861 | } |
| 862 | |
| 863 | #[test] |
no test coverage detected