Skip to main content

truncate

Function truncate 

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

Truncate text to a maximum length with ellipsis.

ยงExample

use vectorless::util::truncate;

assert_eq!(truncate("hello world", 8), "hello...");
assert_eq!(truncate("hi", 10), "hi");