aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/partial_data.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-25 17:42:20 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-25 17:42:20 +0200
commit5ee6edf222658e73ee97871972b6fbeef444451b (patch)
treec9233c7a8584a2d027ef1b7443e3e5b59918ca2b /src/construct/partial_data.rs
parent91dc4b1f461fa76df7163f68b2a6db361a71beea (diff)
downloadmarkdown-rs-5ee6edf222658e73ee97871972b6fbeef444451b.tar.gz
markdown-rs-5ee6edf222658e73ee97871972b6fbeef444451b.tar.bz2
markdown-rs-5ee6edf222658e73ee97871972b6fbeef444451b.zip
Refactor to not pass codes around
Diffstat (limited to '')
-rw-r--r--src/construct/partial_data.rs34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/construct/partial_data.rs b/src/construct/partial_data.rs
index f399bac..86492b5 100644
--- a/src/construct/partial_data.rs
+++ b/src/construct/partial_data.rs
@@ -15,13 +15,13 @@ use crate::tokenizer::{Code, EventType, State, Tokenizer};
/// > | abc
/// ^
/// ```
-pub fn start(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> State {
- if stop.contains(&code) {
+pub fn start(tokenizer: &mut Tokenizer, stop: &'static [Code]) -> State {
+ if stop.contains(&tokenizer.current) {
tokenizer.enter(Token::Data);
- tokenizer.consume(code);
- State::Fn(Box::new(move |t, c| data(t, c, stop)))
+ tokenizer.consume();
+ State::Fn(Box::new(move |t| data(t, stop)))
} else {
- at_break(tokenizer, code, stop)
+ at_break(tokenizer, stop)
}
}
@@ -31,22 +31,22 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> St
/// > | abc
/// ^
/// ```
-fn at_break(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> State {
- match code {
+fn at_break(tokenizer: &mut Tokenizer, stop: &'static [Code]) -> State {
+ match tokenizer.current {
Code::None => State::Ok,
Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => {
tokenizer.enter(Token::LineEnding);
- tokenizer.consume(code);
+ tokenizer.consume();
tokenizer.exit(Token::LineEnding);
- State::Fn(Box::new(move |t, c| at_break(t, c, stop)))
+ State::Fn(Box::new(move |t| at_break(t, stop)))
}
- _ if stop.contains(&code) => {
+ _ if stop.contains(&tokenizer.current) => {
tokenizer.register_resolver("data".to_string(), Box::new(resolve_data));
State::Ok
}
_ => {
tokenizer.enter(Token::Data);
- data(tokenizer, code, stop)
+ data(tokenizer, stop)
}
}
}
@@ -57,19 +57,19 @@ fn at_break(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> Sta
/// > | abc
/// ^^^
/// ```
-fn data(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> State {
- let done = match code {
+fn data(tokenizer: &mut Tokenizer, stop: &'static [Code]) -> State {
+ let done = match tokenizer.current {
Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => true,
- _ if stop.contains(&code) => true,
+ _ if stop.contains(&tokenizer.current) => true,
_ => false,
};
if done {
tokenizer.exit(Token::Data);
- at_break(tokenizer, code, stop)
+ at_break(tokenizer, stop)
} else {
- tokenizer.consume(code);
- State::Fn(Box::new(move |t, c| data(t, c, stop)))
+ tokenizer.consume();
+ State::Fn(Box::new(move |t| data(t, stop)))
}
}