File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -122,8 +122,14 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> {
122
122
valid_up_to = i;
123
123
}
124
124
125
- // SAFETY: `i <= self.source.len()` because it only ever increments by 1
126
- // and the loop is terminated as soon as that goes beyond bounds.
125
+ // SAFETY: `i <= self.source.len()` because it is only ever incremented
126
+ // via `i += 1` and in between every single one of those increments, `i`
127
+ // is compared against `self.source.len()`. That happens either
128
+ // literally by `i < self.source.len()` in the while-loop's condition,
129
+ // or indirectly by `safe_get(self.source, i) & 192 != TAG_CONT_U8`. The
130
+ // loop is terminated as soon as the latest `i += 1` has made `i` no
131
+ // longer less than `self.source.len()`, which means it'll be at most
132
+ // equal to `self.source.len()`.
127
133
let ( inspected, remaining) = unsafe { self . source . split_at_unchecked ( i) } ;
128
134
self . source = remaining;
129
135
You can’t perform that action at this time.
0 commit comments