Skip to main content

truncate_to_width

Function truncate_to_width 

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

Truncate a string to fit within max_width display cells (unicode-safe).

Unlike byte slicing (&s[..n]), this respects multi-byte characters and double-width CJK/emoji glyphs. Returns an owned String.