Expand description
Truncates subject
to a new length
and does not break the words. Guarantees that the truncated string is no longer than length
.
Arguments
subject
- The string to prune.length
- The length to prune the string.end
- The string to be added at the end. Default value is “…”.
Example
use voca_rs::*;
chop::prune("Once upon a time", 7, "");
// => "Once..."
chop::prune("Die Schildkröte fliegt über das Floß.", 19, "~~");
// => "Die Schildkröte~~"
chop::prune("Once upon", 10, "");
// => "Once upon"
chop::prune("Как слышно, приём!", 14, "");
// => "Как слышно..."
use voca_rs::Voca;
"Once upon a time"._prune(7, "");
// => "Once..."