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/attention.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 'src/construct/attention.rs')
-rw-r--r-- | src/construct/attention.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/construct/attention.rs b/src/construct/attention.rs index 42c0965..b4265f0 100644 --- a/src/construct/attention.rs +++ b/src/construct/attention.rs @@ -52,7 +52,7 @@ //! [html-strong]: https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-strong-element use crate::token::Token; -use crate::tokenizer::{Code, Event, EventType, Point, State, StateFnResult, Tokenizer}; +use crate::tokenizer::{Code, Event, EventType, Point, State, Tokenizer}; use crate::unicode::PUNCTUATION; use crate::util::edit_map::EditMap; @@ -169,13 +169,13 @@ struct Sequence { /// > | ** /// ^ /// ``` -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.attention => { tokenizer.enter(Token::AttentionSequence); inside(tokenizer, code, MarkerKind::from_code(code)) } - _ => (State::Nok, 0), + _ => State::Nok, } } @@ -185,16 +185,16 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { /// > | ** /// ^^ /// ``` -fn inside(tokenizer: &mut Tokenizer, code: Code, marker: MarkerKind) -> StateFnResult { +fn inside(tokenizer: &mut Tokenizer, code: Code, marker: MarkerKind) -> State { match code { Code::Char(char) if char == marker.as_char() => { tokenizer.consume(code); - (State::Fn(Box::new(move |t, c| inside(t, c, marker))), 0) + State::Fn(Box::new(move |t, c| inside(t, c, marker))) } _ => { tokenizer.exit(Token::AttentionSequence); tokenizer.register_resolver("attention".to_string(), Box::new(resolve_attention)); - (State::Ok, if matches!(code, Code::None) { 0 } else { 1 }) + State::Ok(if matches!(code, Code::None) { 0 } else { 1 }) } } } @@ -205,7 +205,7 @@ fn resolve_attention(tokenizer: &mut Tokenizer, map: &mut EditMap) -> bool { let codes = &tokenizer.parse_state.codes; let mut start = 0; let mut balance = 0; - let mut sequences: Vec<Sequence> = vec![]; + let mut sequences = vec![]; // Find sequences of sequences and information about them. while start < tokenizer.events.len() { |