Skip to content

Commit

Permalink
refactor(parser): Update signature for 'State::nest'
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Nov 4, 2024
1 parent d7f51c8 commit f8ce339
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions rinja_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,13 +666,13 @@ impl<'a> State<'a> {

fn nest<'b, T, F: Parser<&'b str, T, ErrorContext<'b>>>(
&self,
i: &'b str,
i: &mut &'b str,
mut callback: F,
) -> InputParseResult<'b, T> {
) -> ParseResult<'b, T> {
let prev_level = self.level.get();
let (_, level) = prev_level.nest(i)?;
let (_, level) = prev_level.nest(*i)?;
self.level.set(level);
let ret = callback.parse_peek(i);
let ret = callback.parse_next(i);
self.level.set(prev_level);
ret
}
Expand Down
4 changes: 2 additions & 2 deletions rinja_parser/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<'a> Node<'a> {
}

let start = i;
let (i, tag) = preceded(
let (mut i, tag) = preceded(
|i: &mut _| s.tag_block_start(i),
peek(preceded(
(opt(unpeek(Whitespace::parse)), take_till0(not_ws)),
Expand All @@ -113,7 +113,7 @@ impl<'a> Node<'a> {
_ => return fail.parse_peek(start),
};

let (i, node) = s.nest(i, unpeek(|i| func(i, s)))?;
let node = s.nest(&mut i, unpeek(|i| func(i, s)))?;

let (i, closed) = cut_node(
None,
Expand Down
2 changes: 1 addition & 1 deletion rinja_parser/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<'a> Target<'a> {
/// Parses multiple targets with `or` separating them
pub(super) fn parse(i: &'a str, s: &State<'_>) -> InputParseResult<'a, Self> {
separated1(
unpeek(|i| s.nest(i, unpeek(|i| Self::parse_one(i, s)))),
|i: &mut _| s.nest(i, unpeek(|i| Self::parse_one(i, s))),
ws("or"),
)
.map(|v: Vec<_>| v)
Expand Down

0 comments on commit f8ce339

Please sign in to comment.