Skip to main content

truncate_str

Function truncate_str 

Source
pub fn truncate_str(s: &str, max_bytes: usize) -> &str
Expand description

Safely truncate a string to at most max_bytes bytes without splitting a multi-byte UTF-8 character. Returns the full string if it’s already within the limit.