Skip to content

Commit

Permalink
Merge pull request #678 from epage/till
Browse files Browse the repository at this point in the history
refactor: Clean up ErrMode logic
  • Loading branch information
epage authored Jan 8, 2025
2 parents 7e32086 + df54e83 commit 826cf95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/ascii/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ where
I: FindSlice<(char, char)>,
<I as Stream>::Token: AsChar + Clone,
{
let res = match take_until::<_, _, ()>(0.., ('\r', '\n')).parse_next(input) {
let res = match take_until(0.., ('\r', '\n')).parse_next(input) {
Ok(slice) => slice,
Err(ErrMode::Incomplete(err)) => {
return Err(ErrMode::Incomplete(err));
Err(ErrMode::Backtrack(_)) => input.finish(),
Err(err) => {
return Err(err);
}
Err(_) => input.finish(),
};
if matches!(input.compare("\r"), CompareResult::Ok(_)) {
let comp = input.compare("\r\n");
Expand Down
9 changes: 3 additions & 6 deletions src/combinator/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,9 @@ where
{
#[inline]
fn parse_next(&mut self, i: &mut I) -> PResult<O, E2> {
match self.parser.parse_next(i) {
Ok(ok) => Ok(ok),
Err(ErrMode::Backtrack(e)) => Err(ErrMode::Backtrack(e.into())),
Err(ErrMode::Cut(e)) => Err(ErrMode::Cut(e.into())),
Err(ErrMode::Incomplete(e)) => Err(ErrMode::Incomplete(e)),
}
self.parser
.parse_next(i)
.map_err(|err| err.map(|e| e.into()))
}
}

Expand Down

0 comments on commit 826cf95

Please sign in to comment.