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/scanner.rs | |
| parent | 8207c31aec6336b773fbf4661fdb87625c8b584e (diff) | |
Array and dictionary indexing
Diffstat (limited to 'src/parse/scanner.rs')
| -rw-r--r-- | src/parse/scanner.rs | 9 |
1 files changed, 5 insertions, 4 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) } } |
