aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-13 20:07:27 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-13 20:07:27 +0200
commit1db7caab017b5814d8a8ac3baa5786af18870869 (patch)
tree16b51a8897b9abb392690454b2b8b16555381af8 /src
parent53529258c50b4d95a50f011fc6d9706039cbf118 (diff)
downloadmarkdown-rs-1db7caab017b5814d8a8ac3baa5786af18870869.tar.gz
markdown-rs-1db7caab017b5814d8a8ac3baa5786af18870869.tar.bz2
markdown-rs-1db7caab017b5814d8a8ac3baa5786af18870869.zip
Replace some unused code with assertions
Diffstat (limited to 'src')
-rw-r--r--src/construct/document.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/construct/document.rs b/src/construct/document.rs
index 82f2ebd..daf7131 100644
--- a/src/construct/document.rs
+++ b/src/construct/document.rs
@@ -442,9 +442,11 @@ pub fn flow_end(tokenizer: &mut Tokenizer) -> State {
if tokenizer.tokenize_state.document_continued
!= tokenizer.tokenize_state.document_container_stack.len()
{
- if let Err(message) = exit_containers(tokenizer, &Phase::After) {
- return State::Error(message);
- }
+ let result = exit_containers(tokenizer, &Phase::After);
+ // `Phase::After` doesn’t deal with flow: it only generates exits for
+ // containers.
+ // And that never errors.
+ debug_assert!(result.is_ok(), "did not expect error when exiting");
}
match tokenizer.current {
@@ -523,11 +525,11 @@ fn exit_containers(tokenizer: &mut Tokenizer, phase: &Phase) -> Result<(), Strin
debug_assert!(found, "expected to find container event to exit");
}
- if let Some(ref mut list) = tokenizer.tokenize_state.document_exits[index] {
- list.append(&mut exits);
- } else {
- tokenizer.tokenize_state.document_exits[index] = Some(exits);
- }
+ debug_assert!(
+ tokenizer.tokenize_state.document_exits[index].is_none(),
+ "expected no exits yet"
+ );
+ tokenizer.tokenize_state.document_exits[index] = Some(exits);
}
child.interrupt = false;