aboutsummaryrefslogtreecommitdiffstats
path: root/src/tokenizer.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-12 14:21:53 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-12 14:21:53 +0200
commit504729a4a0c8f3e0d8fc9159e0273150b169e184 (patch)
treea6bf291322decccd6011580337b1feed6151b554 /src/tokenizer.rs
parentdb5a491e6c2223d1db9b458307431a54db3c40f2 (diff)
downloadmarkdown-rs-504729a4a0c8f3e0d8fc9159e0273150b169e184.tar.gz
markdown-rs-504729a4a0c8f3e0d8fc9159e0273150b169e184.tar.bz2
markdown-rs-504729a4a0c8f3e0d8fc9159e0273150b169e184.zip
Refactor to improve docs of each function
Diffstat (limited to 'src/tokenizer.rs')
-rw-r--r--src/tokenizer.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index 0b51c48..3f60b86 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -76,7 +76,7 @@ pub struct Media {
/// Different kinds of attempts.
#[derive(Debug, PartialEq)]
enum AttemptKind {
- /// Discard what was tokenizer when unsuccessful.
+ /// Discard what was tokenized when unsuccessful.
Attempt,
/// Discard always.
Check,
@@ -356,7 +356,7 @@ impl<'a> Tokenizer<'a> {
}
}
- /// Prepare for a next code to get consumed.
+ /// Prepare for a next byte to get consumed.
fn expect(&mut self, byte: Option<u8>) {
debug_assert!(self.consumed, "expected previous byte to be consumed");
self.consumed = false;
@@ -368,11 +368,10 @@ impl<'a> Tokenizer<'a> {
/// used, or call a next function.
pub fn consume(&mut self) {
debug_assert!(!self.consumed, "expected code to not have been consumed: this might be because `x(code)` instead of `x` was returned");
-
self.move_one();
self.previous = self.current;
- // While we’re not at the eof, it is at least better to not have the
+ // While we’re not at eof, it is at least better to not have the
// same current code as `previous` *and* `current`.
self.current = None;
// Mark as consumed.
@@ -427,6 +426,7 @@ impl<'a> Tokenizer<'a> {
self.enter_with_link(name, None);
}
+ /// Enter with a content type.
pub fn enter_with_content(&mut self, name: Name, content_type_opt: Option<Content>) {
self.enter_with_link(
name,
@@ -438,6 +438,7 @@ impl<'a> Tokenizer<'a> {
);
}
+ /// Enter with a link.
pub fn enter_with_link(&mut self, name: Name, link: Option<Link>) {
let mut point = self.point.clone();
move_point_back(self, &mut point);
@@ -663,7 +664,7 @@ fn push_impl(
};
}
State::Retry(name) => {
- log::debug!("retry: {:?}", name);
+ log::debug!("retry: `{:?}`", name);
state = call(tokenizer, name);
}
}