Skip to content

Commit

Permalink
fix(bits): Accept Parser, not parser-like functions (#1599)
Browse files Browse the repository at this point in the history
Co-authored-by: Ed Page <eopage@gmail.com>
  • Loading branch information
Geal and epage committed Dec 30, 2022
1 parent 326344a commit b66ff43
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/bits/mod.rs
Expand Up @@ -5,7 +5,7 @@ pub mod complete;
pub mod streaming;

use crate::error::{ErrorKind, ParseError};
use crate::internal::{Err, IResult, Needed};
use crate::internal::{Err, IResult, Needed, Parser};
use crate::lib::std::ops::RangeFrom;
use crate::traits::{ErrorConvert, Slice};

Expand Down Expand Up @@ -42,9 +42,9 @@ where
E1: ParseError<(I, usize)> + ErrorConvert<E2>,
E2: ParseError<I>,
I: Slice<RangeFrom<usize>>,
P: FnMut((I, usize)) -> IResult<(I, usize), O, E1>,
P: Parser<(I, usize), O, E1>,
{
move |input: I| match parser((input, 0)) {
move |input: I| match parser.parse((input, 0)) {
Ok(((rest, offset), result)) => {
// If the next byte has been partially read, it will be sliced away as well.
// The parser functions might already slice away all fully read bytes.
Expand Down Expand Up @@ -88,7 +88,7 @@ where
E1: ParseError<I> + ErrorConvert<E2>,
E2: ParseError<(I, usize)>,
I: Slice<RangeFrom<usize>> + Clone,
P: FnMut(I) -> IResult<I, O, E1>,
P: Parser<I, O, E1>,
{
move |(input, offset): (I, usize)| {
let inner = if offset % 8 != 0 {
Expand All @@ -97,7 +97,7 @@ where
input.slice((offset / 8)..)
};
let i = (input, offset);
match parser(inner) {
match parser.parse(inner) {
Ok((rest, res)) => Ok(((rest, 0), res)),
Err(Err::Incomplete(Needed::Unknown)) => Err(Err::Incomplete(Needed::Unknown)),
Err(Err::Incomplete(Needed::Size(sz))) => Err(match sz.get().checked_mul(8) {
Expand Down

0 comments on commit b66ff43

Please sign in to comment.