From 5ee6edf222658e73ee97871972b6fbeef444451b Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 25 Jul 2022 17:42:20 +0200 Subject: Refactor to not pass codes around --- src/construct/paragraph.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/construct/paragraph.rs') diff --git a/src/construct/paragraph.rs b/src/construct/paragraph.rs index d320779..4bce6a4 100644 --- a/src/construct/paragraph.rs +++ b/src/construct/paragraph.rs @@ -42,15 +42,15 @@ use crate::util::skip::opt as skip_opt; /// > | abc /// ^ /// ``` -pub fn start(tokenizer: &mut Tokenizer, code: Code) -> State { - match code { +pub fn start(tokenizer: &mut Tokenizer) -> State { + match tokenizer.current { Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { unreachable!("unexpected eol/eof") } _ => { tokenizer.enter(Token::Paragraph); tokenizer.enter_with_content(Token::Data, Some(ContentType::Text)); - inside(tokenizer, code) + inside(tokenizer) } } } @@ -61,8 +61,8 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> State { /// > | abc /// ^^^ /// ``` -fn inside(tokenizer: &mut Tokenizer, code: Code) -> State { - match code { +fn inside(tokenizer: &mut Tokenizer) -> State { + match tokenizer.current { Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { tokenizer.exit(Token::Data); tokenizer.exit(Token::Paragraph); @@ -72,7 +72,7 @@ fn inside(tokenizer: &mut Tokenizer, code: Code) -> State { State::Ok } _ => { - tokenizer.consume(code); + tokenizer.consume(); State::Fn(Box::new(inside)) } } -- cgit