Skip to main content

truncate_byte_budget

Function truncate_byte_budget 

Source
pub fn truncate_byte_budget(
    text: &str,
    max_bytes: usize,
    suffix: &str,
) -> String
Expand description

Truncate a string so that the retained prefix is at most max_bytes bytes, rounded down to the nearest UTF-8 char boundary. Returns the truncated prefix with suffix appended, or the original string when it already fits.