Skip to main content

truncate_string

Function truncate_string 

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

Truncate s to max_width terminal columns, appending … when cut.

Counts display width rather than bytes, so CJK and emoji (two columns each) stay aligned, and a multi-byte character is never split.