diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-10-13 18:14:23 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-10-13 18:14:23 +0200 |
commit | 2f21280db96e9c8086e123f756f5cad27cbfa0bf (patch) | |
tree | 6d3a9f55a0d441984393d612b4bd5f43ffcfbc76 /src/to_mdast.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 'src/to_mdast.rs')
-rw-r--r-- | src/to_mdast.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/to_mdast.rs b/src/to_mdast.rs index 39f6bc5..1d25beb 100644 --- a/src/to_mdast.rs +++ b/src/to_mdast.rs @@ -208,22 +208,14 @@ impl<'a> CompileContext<'a> { let end = point_from_event(ev); let (tree, stack, event_stack) = self.trees.last_mut().expect("Cannot get tail w/o tree"); let node = delve_mut(tree, stack); - node.position_mut() - .expect("Cannot pop manually added node") - .end = end; + let pos = node.position_mut().expect("Cannot pop manually added node"); + pos.end = end; stack.pop().unwrap(); - - if let Some(left_index) = event_stack.pop() { - let left = &self.events[left_index]; - if left.name != ev.name { - on_mismatch_error(self, Some(ev), left)?; - } - } else { - return Err(format!( - "{}:{}: Cannot close `{:?}`, it’s not open", - ev.point.line, ev.point.column, ev.name - )); + let left_index = event_stack.pop().unwrap(); + let left = &self.events[left_index]; + if left.name != ev.name { + on_mismatch_error(self, Some(ev), left)?; } Ok(()) |