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_label.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 'src/construct/partial_label.rs')
-rw-r--r-- | src/construct/partial_label.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/construct/partial_label.rs b/src/construct/partial_label.rs index b1d02e8..0892dbd 100644 --- a/src/construct/partial_label.rs +++ b/src/construct/partial_label.rs @@ -110,9 +110,9 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code, options: Options) -> StateFn tokenizer.consume(code); tokenizer.exit(info.options.marker.clone()); tokenizer.enter(info.options.string.clone()); - (State::Fn(Box::new(|t, c| at_break(t, c, info))), None) + (State::Fn(Box::new(|t, c| at_break(t, c, info))), 0) } - _ => (State::Nok, None), + _ => (State::Nok, 0), } } @@ -124,16 +124,16 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code, options: Options) -> StateFn /// ``` fn at_break(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResult { match code { - Code::None | Code::Char('[') => (State::Nok, None), - Code::Char(']') if !info.data => (State::Nok, None), - _ if info.size > LINK_REFERENCE_SIZE_MAX => (State::Nok, None), + Code::None | Code::Char('[') => (State::Nok, 0), + Code::Char(']') if !info.data => (State::Nok, 0), + _ if info.size > LINK_REFERENCE_SIZE_MAX => (State::Nok, 0), Code::Char(']') => { tokenizer.exit(info.options.string.clone()); tokenizer.enter(info.options.marker.clone()); tokenizer.consume(code); tokenizer.exit(info.options.marker.clone()); tokenizer.exit(info.options.label); - (State::Ok, None) + (State::Ok, 0) } Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => tokenizer.go( space_or_tab_eol_with_options(EolOptions { @@ -179,7 +179,7 @@ fn label(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResult Code::VirtualSpace | Code::Char('\t' | ' ') => { tokenizer.consume(code); info.size += 1; - (State::Fn(Box::new(|t, c| label(t, c, info))), None) + (State::Fn(Box::new(|t, c| label(t, c, info))), 0) } Code::Char('\\') => { tokenizer.consume(code); @@ -187,7 +187,7 @@ fn label(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResult if !info.data { info.data = true; } - (State::Fn(Box::new(|t, c| escape(t, c, info))), None) + (State::Fn(Box::new(|t, c| escape(t, c, info))), 0) } Code::Char(_) => { tokenizer.consume(code); @@ -195,7 +195,7 @@ fn label(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResult if !info.data { info.data = true; } - (State::Fn(Box::new(|t, c| label(t, c, info))), None) + (State::Fn(Box::new(|t, c| label(t, c, info))), 0) } } } @@ -211,7 +211,7 @@ fn escape(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResul Code::Char('[' | '\\' | ']') => { tokenizer.consume(code); info.size += 1; - (State::Fn(Box::new(|t, c| label(t, c, info))), None) + (State::Fn(Box::new(|t, c| label(t, c, info))), 0) } _ => label(tokenizer, code, info), } |