Replace {floor/ceil}_char_boundary polyfills with std (#42599)
Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user