From 2f21280db96e9c8086e123f756f5cad27cbfa0bf Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 13 Oct 2022 18:14:23 +0200 Subject: Refactor some code to improve coverage --- src/to_mdast.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/to_mdast.rs') 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(()) -- cgit