Function voca_rs::chop::truncate [−][src]
pub fn truncate(subject: &str, length: usize, end: &str) -> String
Expand description
Truncates subject
to a new length
.
Arguments
subject
- The string to truncate.length
- The length to truncate the string.end
- The string to be added at the end. Default value is “…”.
Example
use voca_rs::*;
chop::truncate("Once upon a time", 7, "");
// => "Once..."
chop::truncate("Die Schildkröte fliegt über das Floß.", 28, "(...)");
// => "Die Schildkröte fliegt (...)"
chop::truncate("Once upon", 10, "");
// => "Once upon"
use voca_rs::Voca;
"Once upon a time"._truncate(7, "");
// => "Once..."