Skip to main content

truncate

Function truncate 

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

Truncates a string to the given maximum length, appending a marker with the number of omitted characters if truncation occurred.

The cut point is always a UTF-8 char boundary, so multi-byte input (umlauts, emoji, CJK) can never panic the caller.