diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-22 15:03:15 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-22 15:03:15 +0200 |
commit | 41fc406af206e21014eaaba94bcf6b1854f892b3 (patch) | |
tree | 510f6e1d763643da9072f9cf7e097e777fdbd5b8 /src/construct/character_reference.rs | |
parent | 37fad739ba73d488d4c3652caee01f1ec5d0aaaa (diff) | |
download | markdown-rs-41fc406af206e21014eaaba94bcf6b1854f892b3.tar.gz markdown-rs-41fc406af206e21014eaaba94bcf6b1854f892b3.tar.bz2 markdown-rs-41fc406af206e21014eaaba94bcf6b1854f892b3.zip |
Refactor to pass ints instead of vecs around
Diffstat (limited to 'src/construct/character_reference.rs')
-rw-r--r-- | src/construct/character_reference.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/construct/character_reference.rs b/src/construct/character_reference.rs index a4cbec1..2d9d524 100644 --- a/src/construct/character_reference.rs +++ b/src/construct/character_reference.rs @@ -143,9 +143,9 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { tokenizer.enter(Token::CharacterReferenceMarker); tokenizer.consume(code); tokenizer.exit(Token::CharacterReferenceMarker); - (State::Fn(Box::new(open)), None) + (State::Fn(Box::new(open)), 0) } - _ => (State::Nok, None), + _ => (State::Nok, 0), } } @@ -169,7 +169,7 @@ fn open(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { tokenizer.enter(Token::CharacterReferenceMarkerNumeric); tokenizer.consume(code); tokenizer.exit(Token::CharacterReferenceMarkerNumeric); - (State::Fn(Box::new(|t, c| numeric(t, c, info))), None) + (State::Fn(Box::new(|t, c| numeric(t, c, info))), 0) } else { tokenizer.enter(Token::CharacterReferenceValue); value(tokenizer, code, info) @@ -192,7 +192,7 @@ fn numeric(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResu tokenizer.exit(Token::CharacterReferenceMarkerHexadecimal); tokenizer.enter(Token::CharacterReferenceValue); info.kind = Kind::Hexadecimal; - (State::Fn(Box::new(|t, c| value(t, c, info))), None) + (State::Fn(Box::new(|t, c| value(t, c, info))), 0) } else { tokenizer.enter(Token::CharacterReferenceValue); info.kind = Kind::Decimal; @@ -220,25 +220,25 @@ fn value(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResult && !CHARACTER_REFERENCES.iter().any(|d| d.0 == info.buffer); if unknown_named { - (State::Nok, None) + (State::Nok, 0) } else { tokenizer.exit(Token::CharacterReferenceValue); tokenizer.enter(Token::CharacterReferenceMarkerSemi); tokenizer.consume(code); tokenizer.exit(Token::CharacterReferenceMarkerSemi); tokenizer.exit(Token::CharacterReference); - (State::Ok, None) + (State::Ok, 0) } } Code::Char(char) => { if info.buffer.len() < info.kind.max() && info.kind.allowed(char) { info.buffer.push(char); tokenizer.consume(code); - (State::Fn(Box::new(|t, c| value(t, c, info))), None) + (State::Fn(Box::new(|t, c| value(t, c, info))), 0) } else { - (State::Nok, None) + (State::Nok, 0) } } - _ => (State::Nok, None), + _ => (State::Nok, 0), } } |