Skip to content

Commit

Permalink
Support callbacks returning Result<Skip>
Browse files Browse the repository at this point in the history
  • Loading branch information
romamik committed Oct 24, 2024
1 parent 3c81ceb commit 9c10d31
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,25 @@ impl<'s, T: Logos<'s>> CallbackResult<'s, (), T> for Skip {
}
}

impl<'s, E, T: Logos<'s>> CallbackResult<'s, (), T> for Result<Skip, E>
where
E: Into<T::Error>,
{
#[inline]
fn construct<Constructor>(self, _: Constructor, lex: &mut Lexer<'s, T>)
where
Constructor: Fn(()) -> T,
{
match self {
Ok(_) => {
lex.trivia();
T::lex(lex);
}
Err(err) => lex.set(Err(err.into())),
}
}
}

impl<'s, P, T: Logos<'s>> CallbackResult<'s, P, T> for Filter<P> {
#[inline]
fn construct<Constructor>(self, c: Constructor, lex: &mut Lexer<'s, T>)
Expand Down

0 comments on commit 9c10d31

Please sign in to comment.