pub fn truncate_n<'t>(lt: &'t str, n: usize) -> &'t str
Expand description
Trancates the string up to closest to N byte equiv UTF8 if string exceeds size
For example:
ボルテ ‘e3 83 9c e3 83 ab e3 83 86’ with N=3
will give ‘ボ’
ボルテ ‘e3 83 9c e3 83 ab e3 83 86’ with N=4
will give ‘ボ’
ボルテ ‘e3 83 9c e3 83 ab e3 83 86’ with N=1
will give ‘’
§Arguments
-
lt
- a string to truncate -
n
- a size (in bytes, not in chars)
§Returns
- A reference to str with the time
't
which corresponds to the lifetile of the input argument't
.