Skip to main content

truncate_bytes

Function truncate_bytes 

Source
pub fn truncate_bytes(s: &mut String, max_bytes: usize)
Expand description

Truncates a String to at most max_bytes bytes, ensuring the result is valid UTF-8 by finding the nearest character boundary.

If s.len() <= max_bytes, this is a no-op.

Assumption: data in input distribution is almost always shorter than max_bytes.