pub fn truncate_text(text: &str, limit: usize) -> StringExpand description
Truncate text to a limit with ellipsis.
Uses character count rather than byte length to avoid panics on UTF-8 text. Truncates at character boundaries and appends “…” when truncation occurs.
§Example
ⓘ
assert_eq!(truncate_text("hello world", 8), "hello...");
assert_eq!(truncate_text("short", 10), "short");