pub fn truncate(s: &str, max_bytes: usize) -> &strExpand description
Safely truncates a string to a UTF-8-safe prefix sized for truncate_owned.
The returned prefix is at most max_bytes - 3 bytes when truncation is needed,
reserving space for the ellipsis that truncate_owned appends.
Use truncate_owned if you need the truncated string with an appended ellipsis (...).
ยงExamples
use rskit_util::strings::truncate;
assert_eq!(truncate("hello world", 8), "hello");
assert_eq!(truncate("hello", 10), "hello");
assert_eq!(truncate("๐ฆ๐ฆ๐ฆ๐ฆ", 8), "๐ฆ");