diff options
| author | 2022-10-13 18:14:23 +0200 | |
|---|---|---|
| committer | 2022-10-13 18:14:23 +0200 | |
| commit | 2f21280db96e9c8086e123f756f5cad27cbfa0bf (patch) | |
| tree | 6d3a9f55a0d441984393d612b4bd5f43ffcfbc76 /src/tokenizer.rs | |
| parent | 5c7605629d70cc613cb3bee6ac419e7ee4d9cf7f (diff) | |
| download | markdown-rs-2f21280db96e9c8086e123f756f5cad27cbfa0bf.tar.gz markdown-rs-2f21280db96e9c8086e123f756f5cad27cbfa0bf.tar.bz2 markdown-rs-2f21280db96e9c8086e123f756f5cad27cbfa0bf.zip | |
Refactor some code to improve coverage
Diffstat (limited to '')
| -rw-r--r-- | src/tokenizer.rs | 28 | 
1 files changed, 14 insertions, 14 deletions
| diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 84d3d6d..346e04e 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -521,9 +521,7 @@ impl<'a> Tokenizer<'a> {          if VOID_EVENTS.iter().any(|d| d == &name) {              debug_assert!(                  current == previous.name, -                "expected event to be void (`{:?}`), instead of including `{:?}`", -                current, -                previous.name +                "expected event to be void, instead of including something"              );          } @@ -536,12 +534,13 @@ impl<'a> Tokenizer<'a> {          }          log::debug!("exit:    `{:?}`", name); -        self.events.push(Event { +        let event = Event {              kind: Kind::Exit,              name,              point,              link: None, -        }); +        }; +        self.events.push(event);      }      /// Capture the tokenizer progress. @@ -579,13 +578,13 @@ impl<'a> Tokenizer<'a> {          // No need to capture (and restore) when `nok` is `State::Nok`, because the          // parent attempt will do it.          let progress = Some(self.capture()); - -        self.attempts.push(Attempt { +        let attempt = Attempt {              kind: AttemptKind::Check,              progress,              ok,              nok, -        }); +        }; +        self.attempts.push(attempt);      }      /// Stack an attempt, moving to `ok` on [`State::Ok`][] and `nok` on @@ -600,12 +599,13 @@ impl<'a> Tokenizer<'a> {              Some(self.capture())          }; -        self.attempts.push(Attempt { +        let attempt = Attempt {              kind: AttemptKind::Attempt,              progress,              ok,              nok, -        }); +        }; +        self.attempts.push(attempt);      }      /// Tokenize. @@ -629,12 +629,12 @@ impl<'a> Tokenizer<'a> {          if resolve {              let resolvers = self.resolvers.split_off(0);              let mut index = 0; +            let defs = &mut value.definitions; +            let fn_defs = &mut value.gfm_footnote_definitions;              while index < resolvers.len() {                  if let Some(mut result) = call_resolve(self, resolvers[index])? { -                    value -                        .gfm_footnote_definitions -                        .append(&mut result.gfm_footnote_definitions); -                    value.definitions.append(&mut result.definitions); +                    fn_defs.append(&mut result.gfm_footnote_definitions); +                    defs.append(&mut result.definitions);                  }                  index += 1;              } | 
