Skip to main content

truncate_display

Function truncate_display 

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

Truncate s to at most cells terminal columns, marking the cut with an ellipsis.

Returns a string exactly cells columns wide whenever it truncates. A wide character straddling the boundary is dropped rather than split, which can leave the result one column short — the trailing space closes that gap, so callers can rely on the width being exact.