truncate_string

Function truncate_string 

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

Truncate a string to a maximum length with ellipsis.

If the string exceeds max_len, it will be truncated and “…” will be appended.

§Examples

assert_eq!(truncate_string("Hello, World!", 10), "Hello, ...");
assert_eq!(truncate_string("Short", 10), "Short");