Skip to main content

truncate

Function truncate 

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

Truncates a string to max_len characters, appending “…” if truncated.

§Examples

use gor::cmd::util::truncate;

assert_eq!(truncate("hello", 10), "hello");
assert_eq!(truncate("hello world", 5), "hello…");