diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-22 15:03:15 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-22 15:03:15 +0200 |
commit | 41fc406af206e21014eaaba94bcf6b1854f892b3 (patch) | |
tree | 510f6e1d763643da9072f9cf7e097e777fdbd5b8 /src/construct/partial_data.rs | |
parent | 37fad739ba73d488d4c3652caee01f1ec5d0aaaa (diff) | |
download | markdown-rs-41fc406af206e21014eaaba94bcf6b1854f892b3.tar.gz markdown-rs-41fc406af206e21014eaaba94bcf6b1854f892b3.tar.bz2 markdown-rs-41fc406af206e21014eaaba94bcf6b1854f892b3.zip |
Refactor to pass ints instead of vecs around
Diffstat (limited to '')
-rw-r--r-- | src/construct/partial_data.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/construct/partial_data.rs b/src/construct/partial_data.rs index 98b1877..3701e40 100644 --- a/src/construct/partial_data.rs +++ b/src/construct/partial_data.rs @@ -20,7 +20,7 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> St if stop.contains(&code) { tokenizer.enter(Token::Data); tokenizer.consume(code); - (State::Fn(Box::new(move |t, c| data(t, c, stop))), None) + (State::Fn(Box::new(move |t, c| data(t, c, stop))), 0) } else { at_break(tokenizer, code, stop) } @@ -34,16 +34,16 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> St /// ``` fn at_break(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> StateFnResult { match code { - Code::None => (State::Ok, None), + Code::None => (State::Ok, 0), Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { tokenizer.enter(Token::LineEnding); tokenizer.consume(code); tokenizer.exit(Token::LineEnding); - (State::Fn(Box::new(move |t, c| at_break(t, c, stop))), None) + (State::Fn(Box::new(move |t, c| at_break(t, c, stop))), 0) } _ if stop.contains(&code) => { tokenizer.register_resolver("data".to_string(), Box::new(resolve_data)); - (State::Ok, Some(vec![code])) + (State::Ok, if matches!(code, Code::None) { 0 } else { 1 }) } _ => { tokenizer.enter(Token::Data); @@ -70,7 +70,7 @@ fn data(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> StateFn at_break(tokenizer, code, stop) } else { tokenizer.consume(code); - (State::Fn(Box::new(move |t, c| data(t, c, stop))), None) + (State::Fn(Box::new(move |t, c| data(t, c, stop))), 0) } } |