From 6ba11bdaca1721fb4591819604c340d147798f45 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 12 Aug 2022 17:02:01 +0200 Subject: Remove `match` statements if clumsy --- src/construct/thematic_break.rs | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'src/construct/thematic_break.rs') diff --git a/src/construct/thematic_break.rs b/src/construct/thematic_break.rs index b2989cb..af8206e 100644 --- a/src/construct/thematic_break.rs +++ b/src/construct/thematic_break.rs @@ -101,26 +101,22 @@ pub fn before(tokenizer: &mut Tokenizer) -> State { /// ^ /// ``` pub fn at_break(tokenizer: &mut Tokenizer) -> State { - match tokenizer.current { - None | Some(b'\n') if tokenizer.tokenize_state.size >= THEMATIC_BREAK_MARKER_COUNT_MIN => { - tokenizer.tokenize_state.marker = 0; - tokenizer.tokenize_state.size = 0; - tokenizer.exit(Name::ThematicBreak); - // Feel free to interrupt. - tokenizer.interrupt = false; - State::Ok - } - Some(b'*' | b'-' | b'_') - if tokenizer.current.unwrap() == tokenizer.tokenize_state.marker => - { - tokenizer.enter(Name::ThematicBreakSequence); - State::Retry(StateName::ThematicBreakSequence) - } - _ => { - tokenizer.tokenize_state.marker = 0; - tokenizer.tokenize_state.size = 0; - State::Nok - } + if tokenizer.current == Some(tokenizer.tokenize_state.marker) { + tokenizer.enter(Name::ThematicBreakSequence); + State::Retry(StateName::ThematicBreakSequence) + } else if tokenizer.tokenize_state.size >= THEMATIC_BREAK_MARKER_COUNT_MIN + && matches!(tokenizer.current, None | Some(b'\n')) + { + tokenizer.tokenize_state.marker = 0; + tokenizer.tokenize_state.size = 0; + tokenizer.exit(Name::ThematicBreak); + // Feel free to interrupt. + tokenizer.interrupt = false; + State::Ok + } else { + tokenizer.tokenize_state.marker = 0; + tokenizer.tokenize_state.size = 0; + State::Nok } } -- cgit