aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/partial_data.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-29 10:49:07 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-29 10:49:07 +0200
commit148ede7f0f42f0ccb1620b13d91f35d0c7d04c2f (patch)
tree7655ffebe0c6a917c3c391edacde03d754f2de4f /src/construct/partial_data.rs
parent6f61649ac8d08fff85a99172afbf4cd852dda2e6 (diff)
downloadmarkdown-rs-148ede7f0f42f0ccb1620b13d91f35d0c7d04c2f.tar.gz
markdown-rs-148ede7f0f42f0ccb1620b13d91f35d0c7d04c2f.tar.bz2
markdown-rs-148ede7f0f42f0ccb1620b13d91f35d0c7d04c2f.zip
Refactor to work on bytes (`u8`)
Diffstat (limited to 'src/construct/partial_data.rs')
-rw-r--r--src/construct/partial_data.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/construct/partial_data.rs b/src/construct/partial_data.rs
index 0b66b09..335d7ab 100644
--- a/src/construct/partial_data.rs
+++ b/src/construct/partial_data.rs
@@ -15,9 +15,9 @@ use crate::tokenizer::{EventType, State, Tokenizer};
/// > | abc
/// ^
/// ```
-pub fn start(tokenizer: &mut Tokenizer, stop: &'static [char]) -> State {
+pub fn start(tokenizer: &mut Tokenizer, stop: &'static [u8]) -> State {
match tokenizer.current {
- Some(char) if stop.contains(&char) => {
+ Some(byte) if stop.contains(&byte) => {
tokenizer.enter(Token::Data);
tokenizer.consume();
State::Fn(Box::new(move |t| data(t, stop)))
@@ -32,16 +32,16 @@ pub fn start(tokenizer: &mut Tokenizer, stop: &'static [char]) -> State {
/// > | abc
/// ^
/// ```
-fn at_break(tokenizer: &mut Tokenizer, stop: &'static [char]) -> State {
+fn at_break(tokenizer: &mut Tokenizer, stop: &'static [u8]) -> State {
match tokenizer.current {
None => State::Ok,
- Some('\n') => {
+ Some(b'\n') => {
tokenizer.enter(Token::LineEnding);
tokenizer.consume();
tokenizer.exit(Token::LineEnding);
State::Fn(Box::new(move |t| at_break(t, stop)))
}
- Some(char) if stop.contains(&char) => {
+ Some(byte) if stop.contains(&byte) => {
tokenizer.register_resolver_before("data".to_string(), Box::new(resolve_data));
State::Ok
}
@@ -58,10 +58,10 @@ fn at_break(tokenizer: &mut Tokenizer, stop: &'static [char]) -> State {
/// > | abc
/// ^^^
/// ```
-fn data(tokenizer: &mut Tokenizer, stop: &'static [char]) -> State {
+fn data(tokenizer: &mut Tokenizer, stop: &'static [u8]) -> State {
let done = match tokenizer.current {
- None | Some('\n') => true,
- Some(char) if stop.contains(&char) => true,
+ None | Some(b'\n') => true,
+ Some(byte) if stop.contains(&byte) => true,
_ => false,
};