From b945e43103544fc31a0755841b380358b2c161e6 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 22 Jul 2022 17:16:38 +0200 Subject: Refactor to remove unneeded tuples in every states --- src/construct/hard_break_trailing.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/construct/hard_break_trailing.rs') diff --git a/src/construct/hard_break_trailing.rs b/src/construct/hard_break_trailing.rs index c5861f7..8ce4201 100644 --- a/src/construct/hard_break_trailing.rs +++ b/src/construct/hard_break_trailing.rs @@ -42,7 +42,7 @@ use crate::constant::HARD_BREAK_PREFIX_SIZE_MIN; use crate::token::Token; -use crate::tokenizer::{Code, State, StateFnResult, Tokenizer}; +use crate::tokenizer::{Code, State, Tokenizer}; /// Start of a hard break (trailing). /// @@ -51,15 +51,15 @@ use crate::tokenizer::{Code, State, StateFnResult, Tokenizer}; /// ^ /// | b /// ``` -pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { +pub fn start(tokenizer: &mut Tokenizer, code: Code) -> State { match code { Code::Char(' ') if tokenizer.parse_state.constructs.hard_break_trailing => { tokenizer.enter(Token::HardBreakTrailing); tokenizer.enter(Token::HardBreakTrailingSpace); tokenizer.consume(code); - (State::Fn(Box::new(|t, c| inside(t, c, 1))), 0) + State::Fn(Box::new(|t, c| inside(t, c, 1))) } - _ => (State::Nok, 0), + _ => State::Nok, } } @@ -70,19 +70,19 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { /// ^ /// | b /// ``` -fn inside(tokenizer: &mut Tokenizer, code: Code, size: usize) -> StateFnResult { +fn inside(tokenizer: &mut Tokenizer, code: Code, size: usize) -> State { match code { Code::Char(' ') => { tokenizer.consume(code); - (State::Fn(Box::new(move |t, c| inside(t, c, size + 1))), 0) + State::Fn(Box::new(move |t, c| inside(t, c, size + 1))) } Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') if size >= HARD_BREAK_PREFIX_SIZE_MIN => { tokenizer.exit(Token::HardBreakTrailingSpace); tokenizer.exit(Token::HardBreakTrailing); - (State::Ok, if matches!(code, Code::None) { 0 } else { 1 }) + State::Ok(if matches!(code, Code::None) { 0 } else { 1 }) } - _ => (State::Nok, 0), + _ => State::Nok, } } -- cgit