diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-22 17:16:38 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-22 17:16:38 +0200 |
commit | b945e43103544fc31a0755841b380358b2c161e6 (patch) | |
tree | 80c6091c4268e6fec5cce02a08cdf6fa2b434300 /src/content/flow.rs | |
parent | 41fc406af206e21014eaaba94bcf6b1854f892b3 (diff) | |
download | markdown-rs-b945e43103544fc31a0755841b380358b2c161e6.tar.gz markdown-rs-b945e43103544fc31a0755841b380358b2c161e6.tar.bz2 markdown-rs-b945e43103544fc31a0755841b380358b2c161e6.zip |
Refactor to remove unneeded tuples in every states
Diffstat (limited to '')
-rw-r--r-- | src/content/flow.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/content/flow.rs b/src/content/flow.rs index 722e2bb..8aed92b 100644 --- a/src/content/flow.rs +++ b/src/content/flow.rs @@ -27,7 +27,7 @@ use crate::construct::{ thematic_break::start as thematic_break, }; use crate::token::Token; -use crate::tokenizer::{Code, State, StateFnResult, Tokenizer}; +use crate::tokenizer::{Code, State, Tokenizer}; /// Before flow. /// @@ -39,9 +39,9 @@ use crate::tokenizer::{Code, State, StateFnResult, Tokenizer}; /// | bravo /// |*** /// ``` -pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { +pub fn start(tokenizer: &mut Tokenizer, code: Code) -> State { match code { - Code::None => (State::Ok, 0), + Code::None => State::Ok(0), _ => tokenizer.attempt(blank_line, |ok| { Box::new(if ok { blank_line_after } else { initial_before }) })(tokenizer, code), @@ -60,9 +60,9 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { /// |~~~js /// |<div> /// ``` -fn initial_before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { +fn initial_before(tokenizer: &mut Tokenizer, code: Code) -> State { match code { - Code::None => (State::Ok, 0), + Code::None => State::Ok(0), _ => tokenizer.attempt_n( vec![ Box::new(code_indented), @@ -85,16 +85,16 @@ fn initial_before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { /// ```markdown /// ␠␠| /// ``` -fn blank_line_after(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { +fn blank_line_after(tokenizer: &mut Tokenizer, code: Code) -> State { match code { - Code::None => (State::Ok, 0), + Code::None => State::Ok(0), Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { tokenizer.enter(Token::BlankLineEnding); tokenizer.consume(code); tokenizer.exit(Token::BlankLineEnding); // Feel free to interrupt. tokenizer.interrupt = false; - (State::Fn(Box::new(start)), 0) + State::Fn(Box::new(start)) } _ => unreachable!("expected eol/eof"), } @@ -109,14 +109,14 @@ fn blank_line_after(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { /// asd /// ~~~| /// ``` -fn after(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { +fn after(tokenizer: &mut Tokenizer, code: Code) -> State { match code { - Code::None => (State::Ok, 0), + 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(start)), 0) + State::Fn(Box::new(start)) } _ => unreachable!("expected eol/eof"), } @@ -127,6 +127,6 @@ fn after(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { /// ```markdown /// |asd /// ``` -fn before_paragraph(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { +fn before_paragraph(tokenizer: &mut Tokenizer, code: Code) -> State { tokenizer.go(paragraph, after)(tokenizer, code) } |