Replace checked slice indexing by unchecked to support panic-free code
Fixes #126425 Replace the potentially panicking `[]` indexing with `get_unchecked()` to prevent linking with panic-related code.
This commit is contained in:
@@ -88,7 +88,9 @@ unsafe trait GenericRadix: Sized {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let buf = &buf[curr..];
|
// SAFETY: `curr` is initialized to `buf.len()` and is only decremented,
|
||||||
|
// so it is always in bounds.
|
||||||
|
let buf = unsafe { buf.get_unchecked(curr..) };
|
||||||
// SAFETY: The only chars in `buf` are created by `Self::digit` which are assumed to be
|
// SAFETY: The only chars in `buf` are created by `Self::digit` which are assumed to be
|
||||||
// valid UTF-8
|
// valid UTF-8
|
||||||
let buf = unsafe {
|
let buf = unsafe {
|
||||||
|
|||||||
Reference in New Issue
Block a user