Skip to content

Commit 07060be

Browse files
author
Oliver Giersch
committed
replace for-loop (not valid in const fn)
1 parent db2031a commit 07060be

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/core/src/str/validations.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,16 @@ pub(super) const fn run_utf8_validation(buf: &[u8]) -> Result<(), Utf8Error> {
221221
} else {
222222
// byte is < 128 (ASCII), but pointer is not word-aligned, skip
223223
// until the loop reaches the next word-aligned block)
224-
for _ in 0..offset {
224+
let mut i = 0;
225+
while i < offset {
225226
// no need to check alignment again for every byte, so skip
226227
// up to `offset` valid ASCII bytes if possible
227228
curr += 1;
228229
if !(curr < end && buf[curr] < 128) {
229230
break;
230231
}
232+
233+
i += 1;
231234
}
232235
}
233236
} else {

0 commit comments

Comments
 (0)