aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/definition.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-22 15:03:15 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-22 15:03:15 +0200
commit41fc406af206e21014eaaba94bcf6b1854f892b3 (patch)
tree510f6e1d763643da9072f9cf7e097e777fdbd5b8 /src/construct/definition.rs
parent37fad739ba73d488d4c3652caee01f1ec5d0aaaa (diff)
downloadmarkdown-rs-41fc406af206e21014eaaba94bcf6b1854f892b3.tar.gz
markdown-rs-41fc406af206e21014eaaba94bcf6b1854f892b3.tar.bz2
markdown-rs-41fc406af206e21014eaaba94bcf6b1854f892b3.zip
Refactor to pass ints instead of vecs around
Diffstat (limited to 'src/construct/definition.rs')
-rw-r--r--src/construct/definition.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/construct/definition.rs b/src/construct/definition.rs
index 231011f..2016cc4 100644
--- a/src/construct/definition.rs
+++ b/src/construct/definition.rs
@@ -125,7 +125,7 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
// Note: arbitrary whitespace allowed even if code (indented) is on.
tokenizer.attempt_opt(space_or_tab(), before)(tokenizer, code)
} else {
- (State::Nok, None)
+ (State::Nok, 0)
}
}
@@ -151,7 +151,7 @@ fn before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
},
label_after,
)(tokenizer, code),
- _ => (State::Nok, None),
+ _ => (State::Nok, 0),
}
}
@@ -171,10 +171,10 @@ fn label_after(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
State::Fn(Box::new(
tokenizer.attempt_opt(space_or_tab_eol(), destination_before),
)),
- None,
+ 0,
)
}
- _ => (State::Nok, None),
+ _ => (State::Nok, 0),
}
}
@@ -240,9 +240,9 @@ fn after_whitespace(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
tokenizer.exit(Token::Definition);
// You’d be interrupting.
tokenizer.interrupt = true;
- (State::Ok, Some(vec![code]))
+ (State::Ok, if matches!(code, Code::None) { 0 } else { 1 })
}
- _ => (State::Nok, None),
+ _ => (State::Nok, 0),
}
}
@@ -301,8 +301,8 @@ fn title_after(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
fn title_after_after_optional_whitespace(_tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
match code {
Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => {
- (State::Ok, Some(vec![code]))
+ (State::Ok, if matches!(code, Code::None) { 0 } else { 1 })
}
- _ => (State::Nok, None),
+ _ => (State::Nok, 0),
}
}