Trait Ellipse

Source
pub trait Ellipse {
    type Output;

    // Required method
    fn truncate_ellipse_with(&self, len: usize, ellipse: &str) -> Self::Output;

    // Provided method
    fn truncate_ellipse(&self, len: usize) -> Self::Output { ... }
}
Expand description

Truncate and ellipse strings in a human-friendly way.

§Example

use ellipse::Ellipse;

let input = "🇩🇪🇬🇧🇮🇹🇫🇷";
assert_eq!(&input.truncate_ellipse(2), "🇩🇪🇬🇧...");

Required Associated Types§

Required Methods§

Source

fn truncate_ellipse_with(&self, len: usize, ellipse: &str) -> Self::Output

Truncate to a length of len extended grapheme clusters and place the given ellipse string at the end when truncating.

Truncating to a length of 0 will yield the empty element without an attached ellipsis.

Provided Methods§

Source

fn truncate_ellipse(&self, len: usize) -> Self::Output

Truncate to a length of len extended grapheme clusters and add ... at the end of the string when truncating.

Truncating to a length of 0 will yield the empty element without an attached ellipsis.

Implementations on Foreign Types§

Source§

impl<'a> Ellipse for &'a str

Source§

type Output = Cow<'a, str>

Source§

fn truncate_ellipse_with(&self, len: usize, ellipse: &str) -> Self::Output

Implementors§