Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow FnMut for parser predicates #395

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/combinator/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,14 +842,14 @@ where
pub fn separated_foldl1<I, O, O2, E, P, S, Op>(
mut parser: P,
mut sep: S,
op: Op,
mut op: Op,
) -> impl Parser<I, O, E>
where
I: Stream,
P: Parser<I, O, E>,
S: Parser<I, O2, E>,
E: ParserError<I>,
Op: Fn(O, O2, O) -> O,
Op: FnMut(O, O2, O) -> O,
{
trace("separated_foldl1", move |i: &mut I| {
let mut ol = parser.parse_next(i)?;
Expand Down Expand Up @@ -911,14 +911,14 @@ where
pub fn separated_foldr1<I, O, O2, E, P, S, Op>(
mut parser: P,
mut sep: S,
op: Op,
mut op: Op,
) -> impl Parser<I, O, E>
where
I: Stream,
P: Parser<I, O, E>,
S: Parser<I, O2, E>,
E: ParserError<I>,
Op: Fn(O, O2, O) -> O,
Op: FnMut(O, O2, O) -> O,
{
trace("separated_foldr1", move |i: &mut I| {
let ol = parser.parse_next(i)?;
Expand Down
12 changes: 6 additions & 6 deletions src/combinator/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ where
pub struct Map<F, G, I, O, O2, E>
where
F: Parser<I, O, E>,
G: Fn(O) -> O2,
G: FnMut(O) -> O2,
{
parser: F,
map: G,
Expand All @@ -48,7 +48,7 @@ where
impl<F, G, I, O, O2, E> Map<F, G, I, O, O2, E>
where
F: Parser<I, O, E>,
G: Fn(O) -> O2,
G: FnMut(O) -> O2,
{
#[inline(always)]
pub(crate) fn new(parser: F, map: G) -> Self {
Expand All @@ -66,7 +66,7 @@ where
impl<F, G, I, O, O2, E> Parser<I, O2, E> for Map<F, G, I, O, O2, E>
where
F: Parser<I, O, E>,
G: Fn(O) -> O2,
G: FnMut(O) -> O2,
{
#[inline]
fn parse_next(&mut self, i: &mut I) -> PResult<O2, E> {
Expand Down Expand Up @@ -393,7 +393,7 @@ where
pub struct Verify<F, G, I, O, O2, E>
where
F: Parser<I, O, E>,
G: Fn(&O2) -> bool,
G: FnMut(&O2) -> bool,
I: Stream,
O: Borrow<O2>,
O2: ?Sized,
Expand All @@ -410,7 +410,7 @@ where
impl<F, G, I, O, O2, E> Verify<F, G, I, O, O2, E>
where
F: Parser<I, O, E>,
G: Fn(&O2) -> bool,
G: FnMut(&O2) -> bool,
I: Stream,
O: Borrow<O2>,
O2: ?Sized,
Expand All @@ -432,7 +432,7 @@ where
impl<F, G, I, O, O2, E> Parser<I, O, E> for Verify<F, G, I, O, O2, E>
where
F: Parser<I, O, E>,
G: Fn(&O2) -> bool,
G: FnMut(&O2) -> bool,
I: Stream,
O: Borrow<O2>,
O2: ?Sized,
Expand Down
4 changes: 2 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ pub trait Parser<I, O, E> {
#[inline(always)]
fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
where
G: Fn(O) -> O2,
G: FnMut(O) -> O2,
Self: core::marker::Sized,
{
Map::new(self, map)
Expand Down Expand Up @@ -581,7 +581,7 @@ pub trait Parser<I, O, E> {
fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
where
Self: core::marker::Sized,
G: Fn(&O2) -> bool,
G: FnMut(&O2) -> bool,
I: Stream,
O: crate::lib::std::borrow::Borrow<O2>,
O2: ?Sized,
Expand Down
Loading