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_destination.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_destination.rs')
-rw-r--r-- | src/construct/partial_destination.rs | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/src/construct/partial_destination.rs b/src/construct/partial_destination.rs index dc5c904..29cb5c4 100644 --- a/src/construct/partial_destination.rs +++ b/src/construct/partial_destination.rs @@ -174,38 +174,39 @@ pub fn enclosed_escape(tokenizer: &mut Tokenizer) -> State { /// ^ /// ``` pub fn raw(tokenizer: &mut Tokenizer) -> State { - match tokenizer.current { - None | Some(b'\t' | b'\n' | b' ' | b')') if tokenizer.tokenize_state.size == 0 => { - tokenizer.exit(Name::Data); - tokenizer.exit(tokenizer.tokenize_state.token_5.clone()); - tokenizer.exit(tokenizer.tokenize_state.token_4.clone()); - tokenizer.exit(tokenizer.tokenize_state.token_1.clone()); - tokenizer.tokenize_state.size = 0; - State::Ok - } - Some(b'(') if tokenizer.tokenize_state.size < tokenizer.tokenize_state.size_b => { - tokenizer.consume(); - tokenizer.tokenize_state.size += 1; - State::Next(StateName::DestinationRaw) - } - // ASCII control (but *not* `\0`) and space and `(`. - None | Some(0x01..=0x1F | b' ' | b'(' | 0x7F) => { - tokenizer.tokenize_state.size = 0; - State::Nok - } - Some(b')') => { - tokenizer.consume(); - tokenizer.tokenize_state.size -= 1; - State::Next(StateName::DestinationRaw) - } - Some(b'\\') => { - tokenizer.consume(); - State::Next(StateName::DestinationRawEscape) - } - Some(_) => { - tokenizer.consume(); - State::Next(StateName::DestinationRaw) - } + if tokenizer.tokenize_state.size == 0 + && matches!(tokenizer.current, None | Some(b'\t' | b'\n' | b' ' | b')')) + { + tokenizer.exit(Name::Data); + tokenizer.exit(tokenizer.tokenize_state.token_5.clone()); + tokenizer.exit(tokenizer.tokenize_state.token_4.clone()); + tokenizer.exit(tokenizer.tokenize_state.token_1.clone()); + tokenizer.tokenize_state.size = 0; + State::Ok + } else if tokenizer.tokenize_state.size < tokenizer.tokenize_state.size_b + && tokenizer.current == Some(b'(') + { + tokenizer.consume(); + tokenizer.tokenize_state.size += 1; + State::Next(StateName::DestinationRaw) + } else if tokenizer.current == Some(b')') { + tokenizer.consume(); + tokenizer.tokenize_state.size -= 1; + State::Next(StateName::DestinationRaw) + } + // ASCII control (but *not* `\0`) and space and `(`. + else if matches!( + tokenizer.current, + None | Some(0x01..=0x1F | b' ' | b'(' | 0x7F) + ) { + tokenizer.tokenize_state.size = 0; + State::Nok + } else if tokenizer.current == Some(b'\\') { + tokenizer.consume(); + State::Next(StateName::DestinationRawEscape) + } else { + tokenizer.consume(); + State::Next(StateName::DestinationRaw) } } |