Function goose::util::truncate_string [−][src]
Expand description
Truncate strings when they’re too long to display.
If a string is longer than the specified max length, this function removes extra the characters and replaces the last two with a double-period ellipsis.
Example
use goose::util;
// All but 7 characters are truncated, with ".." appended.
assert_eq!(util::truncate_string("this is a long string", 9), "this is..");
// All characters are returned as the string is less than 15 characters long.
assert_eq!(util::truncate_string("shorter string", 15), "shorter string");