Skip to main content

truncate_for_display

Function truncate_for_display 

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

Truncate a string to at most max_chars Unicode scalar values, appending "..." when truncation occurs.

Safe on multibyte input: never slices inside a UTF-8 code point.