Skip to main content

Module abbreviate

Module abbreviate 

Source
Expand description

String abbreviation utilities.

This module provides functions for abbreviating strings to a specified length, adding ellipsis or custom markers to indicate truncation.

§Usage

Import the StringAbbreviate trait to use methods directly on strings:

use rstring::StringAbbreviate;

assert_eq!("abcdefg".abbreviate(6).unwrap(), "abc...");
assert_eq!("abcdefg".abbreviate(7).unwrap(), "abcdefg");
assert_eq!("abcdef".abbreviate_middle(".", 4), "ab.f");
assert_eq!("abcdef".overlay("zzzz", 2, 4), "abzzzzef");

Structs§

AbbreviateError

Traits§

StringAbbreviate
Extension trait for string abbreviation methods.