aboutsummaryrefslogtreecommitdiffstats
path: root/src/subtokenize.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-28 16:51:25 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-28 16:51:25 +0200
commit6f61649ac8d08fff85a99172afbf4cd852dda2e6 (patch)
treefecb8227527337613c85ba731d7a01f270330a7f /src/subtokenize.rs
parentf7e5fb852dc9c416b9eeb1f0d4f2d51ba5b68456 (diff)
downloadmarkdown-rs-6f61649ac8d08fff85a99172afbf4cd852dda2e6.tar.gz
markdown-rs-6f61649ac8d08fff85a99172afbf4cd852dda2e6.tar.bz2
markdown-rs-6f61649ac8d08fff85a99172afbf4cd852dda2e6.zip
Refactor to use `debug_assert`
Diffstat (limited to 'src/subtokenize.rs')
-rw-r--r--src/subtokenize.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/subtokenize.rs b/src/subtokenize.rs
index a78f5e2..c641419 100644
--- a/src/subtokenize.rs
+++ b/src/subtokenize.rs
@@ -37,10 +37,10 @@ pub fn link(events: &mut [Event], index: usize) {
/// Link two arbitrary [`Event`][]s together.
pub fn link_to(events: &mut [Event], pevious: usize, next: usize) {
- assert_eq!(events[pevious].event_type, EventType::Enter);
- assert_eq!(events[pevious + 1].event_type, EventType::Exit);
- assert_eq!(events[pevious + 1].token_type, events[pevious].token_type);
- assert_eq!(events[next].event_type, EventType::Enter);
+ debug_assert_eq!(events[pevious].event_type, EventType::Enter);
+ debug_assert_eq!(events[pevious + 1].event_type, EventType::Exit);
+ debug_assert_eq!(events[pevious + 1].token_type, events[pevious].token_type);
+ debug_assert_eq!(events[next].event_type, EventType::Enter);
// Note: the exit of this event may not exist, so don’t check for that.
let link_previous = events[pevious]
@@ -51,7 +51,7 @@ pub fn link_to(events: &mut [Event], pevious: usize, next: usize) {
let link_next = events[next].link.as_mut().expect("expected `link` on next");
link_next.previous = Some(pevious);
- assert_eq!(
+ debug_assert_eq!(
events[pevious].link.as_ref().unwrap().content_type,
events[next].link.as_ref().unwrap().content_type
);
@@ -70,7 +70,7 @@ pub fn subtokenize(events: &mut Vec<Event>, parse_state: &ParseState) -> bool {
// Find each first opening chunk.
if let Some(ref link) = event.link {
- assert_eq!(event.event_type, EventType::Enter);
+ debug_assert_eq!(event.event_type, EventType::Enter);
// No need to enter linked events again.
if link.previous == None {
@@ -89,7 +89,7 @@ pub fn subtokenize(events: &mut Vec<Event>, parse_state: &ParseState) -> bool {
while let Some(index) = link_index {
let enter = &events[index];
let link_curr = enter.link.as_ref().expect("expected link");
- assert_eq!(enter.event_type, EventType::Enter);
+ debug_assert_eq!(enter.event_type, EventType::Enter);
if link_curr.previous != None {
tokenizer.define_skip(&enter.point);