Replace {floor/ceil}_char_boundary polyfills with std (#42599)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-11-13 08:11:18 +00:00
committed by GitHub
parent 1fc0642de1
commit b92b28314f
4 changed files with 18 additions and 134 deletions
+6
View File
@@ -51,6 +51,12 @@ macro_rules! debug_panic {
};
}
#[inline]
pub const fn is_utf8_char_boundary(u8: u8) -> bool {
// This is bit magic equivalent to: b < 128 || b >= 192
(u8 as i8) >= -0x40
}
pub fn truncate(s: &str, max_chars: usize) -> &str {
match s.char_indices().nth(max_chars) {
None => s,