Skip to main content

truncate_string

Function truncate_string 

Source
pub fn truncate_string(s: &str, max_chars: usize) -> String
Expand description

Truncate a string to max_chars, preserving word boundaries. The returned string will be at most max_chars characters long (including ellipsis). Safe for non-ASCII (UTF-8 multi-byte characters).