aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/partial_space_or_tab_eol.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-13 20:38:00 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-13 20:38:00 +0200
commitec1cee9d7e01722b1d87552bb5f7b0cab7602af6 (patch)
tree43985129ec1ee613288eb553545f613fd31af095 /src/construct/partial_space_or_tab_eol.rs
parented23a4a3630d0f06f86f8482ecb495ccf0892e62 (diff)
downloadmarkdown-rs-ec1cee9d7e01722b1d87552bb5f7b0cab7602af6.tar.gz
markdown-rs-ec1cee9d7e01722b1d87552bb5f7b0cab7602af6.tar.bz2
markdown-rs-ec1cee9d7e01722b1d87552bb5f7b0cab7602af6.zip
Replace some unused code for assertions
Diffstat (limited to 'src/construct/partial_space_or_tab_eol.rs')
-rw-r--r--src/construct/partial_space_or_tab_eol.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/construct/partial_space_or_tab_eol.rs b/src/construct/partial_space_or_tab_eol.rs
index 1247639..93f6af2 100644
--- a/src/construct/partial_space_or_tab_eol.rs
+++ b/src/construct/partial_space_or_tab_eol.rs
@@ -82,8 +82,7 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
},
))
}
- Some(b'\n') => State::Retry(StateName::SpaceOrTabEolAtEol),
- _ => State::Nok,
+ _ => State::Retry(StateName::SpaceOrTabEolAtEol),
}
}
@@ -98,11 +97,11 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
/// ```
pub fn after_first(tokenizer: &mut Tokenizer) -> State {
tokenizer.tokenize_state.space_or_tab_eol_ok = true;
-
- if tokenizer.tokenize_state.space_or_tab_eol_content.is_some() {
- tokenizer.tokenize_state.space_or_tab_eol_connect = true;
- }
-
+ debug_assert!(
+ tokenizer.tokenize_state.space_or_tab_eol_content.is_none(),
+ "expected no content"
+ );
+ // If the above ever errors, set `tokenizer.tokenize_state.space_or_tab_eol_connect: true` in that case.
State::Retry(StateName::SpaceOrTabEolAtEol)
}
@@ -195,14 +194,15 @@ pub fn after_eol(tokenizer: &mut Tokenizer) -> State {
/// ^
/// ```
pub fn after_more(tokenizer: &mut Tokenizer) -> State {
+ debug_assert!(
+ !matches!(tokenizer.current, None | Some(b'\n')),
+ "did not expect blank line"
+ );
+ // If the above ever starts erroring, gracefully `State::Nok` on it.
+ // Currently it doesn’t happen, as we only use this in content, which does
+ // not allow blank lines.
tokenizer.tokenize_state.space_or_tab_eol_content = None;
tokenizer.tokenize_state.space_or_tab_eol_connect = false;
tokenizer.tokenize_state.space_or_tab_eol_ok = false;
-
- // Blank line not allowed.
- if matches!(tokenizer.current, None | Some(b'\n')) {
- State::Nok
- } else {
- State::Ok
- }
+ State::Ok
}