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/construct/partial_data.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/construct/partial_data.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/construct/partial_data.rs b/src/construct/partial_data.rs index 3701e40..11064e6 100644 --- a/src/construct/partial_data.rs +++ b/src/construct/partial_data.rs @@ -7,7 +7,7 @@ //! [text]: crate::content::text use crate::token::Token; -use crate::tokenizer::{Code, EventType, State, StateFnResult, Tokenizer}; +use crate::tokenizer::{Code, EventType, State, Tokenizer}; use crate::util::edit_map::EditMap; /// At the beginning of data. @@ -16,11 +16,11 @@ use crate::util::edit_map::EditMap; /// > | abc /// ^ /// ``` -pub fn start(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> StateFnResult { +pub fn start(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> State { if stop.contains(&code) { tokenizer.enter(Token::Data); tokenizer.consume(code); - (State::Fn(Box::new(move |t, c| data(t, c, stop))), 0) + State::Fn(Box::new(move |t, c| data(t, c, stop))) } else { at_break(tokenizer, code, stop) } @@ -32,18 +32,18 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> St /// > | abc /// ^ /// ``` -fn at_break(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> StateFnResult { +fn at_break(tokenizer: &mut Tokenizer, code: Code, stop: &'static [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(move |t, c| at_break(t, c, stop))), 0) + State::Fn(Box::new(move |t, c| at_break(t, c, stop))) } _ if stop.contains(&code) => { tokenizer.register_resolver("data".to_string(), Box::new(resolve_data)); - (State::Ok, if matches!(code, Code::None) { 0 } else { 1 }) + State::Ok(if matches!(code, Code::None) { 0 } else { 1 }) } _ => { tokenizer.enter(Token::Data); @@ -58,7 +58,7 @@ fn at_break(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> Sta /// > | abc /// ^^^ /// ``` -fn data(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> StateFnResult { +fn data(tokenizer: &mut Tokenizer, code: Code, stop: &'static [Code]) -> State { let done = match code { Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => true, _ if stop.contains(&code) => true, @@ -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))), 0) + State::Fn(Box::new(move |t, c| data(t, c, stop))) } } |