diff --git a/src/block.rs b/src/block.rs index d108c62..7595bd4 100644 --- a/src/block.rs +++ b/src/block.rs @@ -215,7 +215,7 @@ impl<'s> TreeParser<'s> { // close list if a non list item or a list item of new type appeared if let Some(OpenList { ty, depth, .. }) = self.open_lists.last() { - assert!(usize::from(*depth) <= self.tree.depth()); + debug_assert!(usize::from(*depth) <= self.tree.depth()); if self.tree.depth() == (*depth).into() && !matches!(kind, Kind::ListItem { ty: ty_new, .. } if *ty == ty_new) { @@ -405,7 +405,7 @@ impl<'s> TreeParser<'s> { } if let Some(OpenList { depth, .. }) = self.open_lists.last() { - assert!(usize::from(*depth) <= self.tree.depth()); + debug_assert!(usize::from(*depth) <= self.tree.depth()); if self.tree.depth() == (*depth).into() { self.prev_blankline = false; self.prev_loose = false; diff --git a/src/html.rs b/src/html.rs index bd105c8..2dfd22a 100644 --- a/src/html.rs +++ b/src/html.rs @@ -96,7 +96,7 @@ impl Render for Renderer { Container::DescriptionList => out.write_str(" out.write_str(" { - assert!(self.footnote_number.is_none()); + debug_assert!(self.footnote_number.is_none()); self.footnote_number = Some((*number).try_into().unwrap()); if !self.encountered_footnote { self.encountered_footnote = true; diff --git a/src/inline.rs b/src/inline.rs index 38bbbf6..49e1f15 100644 --- a/src/inline.rs +++ b/src/inline.rs @@ -504,7 +504,7 @@ impl + Clone> Parser { ) ) { - assert_eq!(self.events[e_opener].span, event_closer.span); + debug_assert_eq!(self.events[e_opener].span, event_closer.span); event_closer.span = inner_span; self.events[e_opener].span = inner_span; } diff --git a/src/lib.rs b/src/lib.rs index f5ddb78..01b58ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -993,7 +993,7 @@ impl<'s> Parser<'s> { class: (!ev.span.is_empty()).then(|| content), }, block::Container::Footnote => { - assert!(enter); + debug_assert!(enter); self.footnotes.insert(content, self.tree.take_branch()); self.block_attributes = Attributes::new(); continue; diff --git a/src/tree.rs b/src/tree.rs index f0648dd..8d023ad 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -79,7 +79,7 @@ impl Tree { std::iter::from_fn(move || { head.take().map(|h| { let n = &self.nodes[h.index()]; - assert!(matches!(n.kind, NodeKind::Inline)); + debug_assert!(matches!(n.kind, NodeKind::Inline)); head = n.next; n.span }) @@ -126,7 +126,7 @@ pub struct NodeIndex(std::num::NonZeroUsize); impl NodeIndex { fn new(i: usize) -> Self { - assert_ne!(i, usize::MAX); + debug_assert_ne!(i, usize::MAX); Self((i + 1).try_into().unwrap()) } @@ -246,7 +246,7 @@ impl Builder { } } else { let last = self.branch.pop(); - assert_ne!(last, None); + debug_assert_ne!(last, None); } } @@ -314,7 +314,7 @@ impl Builder { } pub(super) fn finish(self) -> Tree { - assert_eq!(self.depth, 0); + debug_assert_eq!(self.depth, 0); let head = self.nodes[NodeIndex::root().index()].next; Tree { nodes: self.nodes.into_boxed_slice().into(), @@ -331,19 +331,19 @@ impl Builder { match &mut head.kind { NodeKind::Root | NodeKind::Inline | NodeKind::Atom(_) => { // set next pointer of previous node - assert_eq!(head.next, None); + debug_assert_eq!(head.next, None); head.next = Some(ni); } NodeKind::Container(_, child) => { self.branch.push(*head_ni); // set child pointer of current container - assert_eq!(*child, None); + debug_assert_eq!(*child, None); *child = Some(ni); } } } else if let Some(block) = self.branch.pop() { let mut block = &mut self.nodes[block.index()]; - assert!(matches!(block.kind, NodeKind::Container(..))); + debug_assert!(matches!(block.kind, NodeKind::Container(..))); block.next = Some(ni); } else { panic!()