refactor(parser): Switch 'impl FnMut' to 'impl Parser'

This commit is contained in:
Ed Page 2024-10-25 09:06:14 -05:00
parent 25067bdb4e
commit 88c702e6a8
2 changed files with 7 additions and 7 deletions

View File

@ -286,8 +286,8 @@ fn not_ws(c: char) -> bool {
}
fn ws<'a, O>(
inner: impl FnMut(&'a str) -> ParseResult<'a, O>,
) -> impl FnMut(&'a str) -> ParseResult<'a, O> {
inner: impl Parser<&'a str, O, ErrorContext<'a>>,
) -> impl Parser<&'a str, O, ErrorContext<'a>> {
delimited(take_till(not_ws), inner, take_till(not_ws))
}
@ -295,8 +295,8 @@ fn ws<'a, O>(
/// Returns tuple that would be returned when parsing `end`.
fn skip_till<'a, 'b, O>(
candidate_finder: impl crate::memchr_splitter::Splitter,
end: impl FnMut(&'a str) -> ParseResult<'a, O>,
) -> impl FnMut(&'a str) -> ParseResult<'a, (&'a str, O)> {
end: impl Parser<&'a str, O, ErrorContext<'a>>,
) -> impl Parser<&'a str, (&'a str, O), ErrorContext<'a>> {
let mut next = alt((map(end, Some), map(anychar, |_| None)));
move |start: &'a str| {
let mut i = start;
@ -318,7 +318,7 @@ fn skip_till<'a, 'b, O>(
}
}
fn keyword<'a>(k: &'a str) -> impl FnMut(&'a str) -> ParseResult<'a> {
fn keyword<'a>(k: &'a str) -> impl Parser<&'a str, &'a str, ErrorContext<'a>> {
move |i: &'a str| -> ParseResult<'a> {
let (j, v) = identifier.parse_next(i)?;
if k == v { Ok((j, v)) } else { fail(i) }

View File

@ -210,8 +210,8 @@ impl<'a> Node<'a> {
fn cut_node<'a, O>(
kind: Option<&'static str>,
inner: impl FnMut(&'a str) -> ParseResult<'a, O>,
) -> impl FnMut(&'a str) -> ParseResult<'a, O> {
inner: impl Parser<&'a str, O, ErrorContext<'a>>,
) -> impl Parser<&'a str, O, ErrorContext<'a>> {
let mut inner = cut(inner);
move |i: &'a str| {
let result = inner.parse_next(i);