diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-08-12 17:02:01 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-08-12 17:02:01 +0200 |
commit | 6ba11bdaca1721fb4591819604c340d147798f45 (patch) | |
tree | ef602b518043c0a7228e76d9d00bee95a17798d4 /src/construct/partial_space_or_tab.rs | |
parent | 504729a4a0c8f3e0d8fc9159e0273150b169e184 (diff) | |
download | markdown-rs-6ba11bdaca1721fb4591819604c340d147798f45.tar.gz markdown-rs-6ba11bdaca1721fb4591819604c340d147798f45.tar.bz2 markdown-rs-6ba11bdaca1721fb4591819604c340d147798f45.zip |
Remove `match` statements if clumsy
Diffstat (limited to 'src/construct/partial_space_or_tab.rs')
-rw-r--r-- | src/construct/partial_space_or_tab.rs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/construct/partial_space_or_tab.rs b/src/construct/partial_space_or_tab.rs index 5f1b4cf..9637373 100644 --- a/src/construct/partial_space_or_tab.rs +++ b/src/construct/partial_space_or_tab.rs @@ -68,23 +68,24 @@ pub fn space_or_tab_with_options(tokenizer: &mut Tokenizer, options: Options) -> /// ^ /// ``` pub fn start(tokenizer: &mut Tokenizer) -> State { - match tokenizer.current { - Some(b'\t' | b' ') if tokenizer.tokenize_state.space_or_tab_max > 0 => { - tokenizer.enter_with_content( - tokenizer.tokenize_state.space_or_tab_token.clone(), - tokenizer.tokenize_state.space_or_tab_content_type.clone(), - ); - - if tokenizer.tokenize_state.space_or_tab_connect { - let index = tokenizer.events.len() - 1; - link(&mut tokenizer.events, index); - } else if tokenizer.tokenize_state.space_or_tab_content_type.is_some() { - tokenizer.tokenize_state.space_or_tab_connect = true; - } + if tokenizer.tokenize_state.space_or_tab_max > 0 + && matches!(tokenizer.current, Some(b'\t' | b' ')) + { + tokenizer.enter_with_content( + tokenizer.tokenize_state.space_or_tab_token.clone(), + tokenizer.tokenize_state.space_or_tab_content_type.clone(), + ); - State::Retry(StateName::SpaceOrTabInside) + if tokenizer.tokenize_state.space_or_tab_connect { + let index = tokenizer.events.len() - 1; + link(&mut tokenizer.events, index); + } else if tokenizer.tokenize_state.space_or_tab_content_type.is_some() { + tokenizer.tokenize_state.space_or_tab_connect = true; } - _ => State::Retry(StateName::SpaceOrTabAfter), + + State::Retry(StateName::SpaceOrTabInside) + } else { + State::Retry(StateName::SpaceOrTabAfter) } } |