From 8f8d72a749a39845fd03ae259533abe73dc7dcdf Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 9 Aug 2022 14:04:27 +0200 Subject: Add support for passing `ok`, `nok` as separate states to attempts --- src/construct/partial_space_or_tab.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/construct/partial_space_or_tab.rs') diff --git a/src/construct/partial_space_or_tab.rs b/src/construct/partial_space_or_tab.rs index b0b35a6..0b63b0e 100644 --- a/src/construct/partial_space_or_tab.rs +++ b/src/construct/partial_space_or_tab.rs @@ -180,13 +180,11 @@ pub fn eol_start(tokenizer: &mut Tokenizer) -> State { }, ); - tokenizer.attempt(state_name, move |ok| { - State::Fn(if ok { - StateName::SpaceOrTabEolAfterFirst - } else { - StateName::SpaceOrTabEolAtEol - }) - }) + tokenizer.attempt( + state_name, + State::Fn(StateName::SpaceOrTabEolAfterFirst), + State::Fn(StateName::SpaceOrTabEolAtEol), + ) } pub fn eol_after_first(tokenizer: &mut Tokenizer) -> State { @@ -269,7 +267,11 @@ pub fn eol_after_eol(tokenizer: &mut Tokenizer) -> State { connect: tokenizer.tokenize_state.space_or_tab_eol_connect, }, ); - tokenizer.attempt_opt(state_name, StateName::SpaceOrTabEolAfterMore) + tokenizer.attempt( + state_name, + State::Fn(StateName::SpaceOrTabEolAfterMore), + State::Fn(StateName::SpaceOrTabEolAfterMore), + ) } /// `space_or_tab_eol`: after more (optional) `space_or_tab`. -- cgit