Skip to content

Commit

Permalink
New parser function: try_with
Browse files Browse the repository at this point in the history
  • Loading branch information
sabitheotome committed Apr 12, 2024
1 parent 96a6928 commit d3357e0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/parser/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use super::adapters::{
slice::Slice,
spanned::Spanned,
then::Then,
try_with::TryWith,
unwrapped::Unwrapped,
};
use super::util::assoc::{err, val};
Expand Down Expand Up @@ -248,6 +249,18 @@ pub trait Parser {
Or::new(self, parser)
}

// TODO: Documentation
fn try_with<Par, Fun, Out>(self, parser: Par, function: Fun) -> TryWith<Self, Par, Fun>
where
Self: Sized,
Self: Parser<Output = Out>,
Par: Parser<Output = Out, Input = Self::Input>,
Fun: Fn(Out::Value, Out::Value) -> std::ops::ControlFlow<Out::Value, Out::Value>,
Out: Response + Fallible,
{
TryWith::new(self, parser, function)
}

// TODO: Documentation
fn repeat(self) -> Repeat<Self>
where
Expand Down

0 comments on commit d3357e0

Please sign in to comment.