pub fn truncate_width(s: &str, max_width: usize) -> StringExpand description
Truncate a string to a maximum display width, adding “…” if truncated.
This accounts for unicode character display widths (e.g., CJK characters take 2 columns, emoji may take 2, etc.). Essential for TUI rendering.
§Example
ⓘ
let result = truncate_width("Hello, World!", 8);
assert_eq!(result, "Hello,…");