diff options
Diffstat (limited to 'src/construct/partial_data.rs')
-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))) } } |