diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-08-12 13:39:33 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-12 13:56:23 +0200 |
| commit | eaa3cbaa9c2b1564a4b0db013672245a1893314a (patch) | |
| tree | 616a3d0f3686793caffcef72f230f8ba79b8f3ca /src/parse | |
| parent | 8207c31aec6336b773fbf4661fdb87625c8b584e (diff) | |
Array and dictionary indexing
Diffstat (limited to 'src/parse')
| -rw-r--r-- | src/parse/scanner.rs | 9 | ||||
| -rw-r--r-- | src/parse/tokens.rs | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/parse/scanner.rs b/src/parse/scanner.rs index bb827255..f893c4d3 100644 --- a/src/parse/scanner.rs +++ b/src/parse/scanner.rs @@ -128,9 +128,10 @@ impl<'s> Scanner<'s> { /// The remaining source string after the current index. #[inline] pub fn rest(&self) -> &'s str { - // SAFETY: The index is always in bounds and on a codepoint boundary - // since it is: - // - either increased by the length of a scanned character, + // Safety: The index is always in bounds and on a codepoint boundary + // since it starts at zero and is is: + // - either increased by the length of a scanned character, advacing + // from one codepoint boundary to the next, // - or checked upon jumping. unsafe { self.src.get_unchecked(self.index ..) } } @@ -138,7 +139,7 @@ impl<'s> Scanner<'s> { /// The full source string up to the current index. #[inline] pub fn eaten(&self) -> &'s str { - // SAFETY: The index is always okay, for details see `rest()`. + // Safety: The index is always okay, for details see `rest()`. unsafe { self.src.get_unchecked(.. self.index) } } diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs index 9fd13ecc..acd939e8 100644 --- a/src/parse/tokens.rs +++ b/src/parse/tokens.rs @@ -595,9 +595,9 @@ mod tests { // Test with each applicable suffix. for &(block, mode, suffix, token) in SUFFIXES { let src = $src; - #[allow(unused)] - let mut blocks = BLOCKS; - $(blocks = $blocks;)? + #[allow(unused_variables)] + let blocks = BLOCKS; + $(let blocks = $blocks;)? assert!(!blocks.contains(|c| !BLOCKS.contains(c))); if (mode.is_none() || mode == Some($mode)) && blocks.contains(block) { t!(@$mode: format!("{}{}", src, suffix) => $($token,)* token); |
