Skip to main content

truncate_owned

Function truncate_owned 

Source
pub fn truncate_owned(s: &str, max_cols: impl Into<usize>) -> String
Expand description

Owned variant of truncate: truncate s to max_cols display columns and copy the surviving prefix into a new String.

Prefer truncate on hot paths (it borrows instead of allocating); reach for this only when an owned String is actually needed.