[][src]Function voca_rs::chop::prune

pub fn prune(subject: &str, length: usize, end: &str) -> String

Truncates subject to a new length and does not break the words. Guarantees that the truncated string is no longer than length.

Arguments

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..."