Skip to main content

truncate_str

Function truncate_str 

Source
pub fn truncate_str(str: &str, range: Range<u64>) -> &str
Expand description

Borrows a prefix ending at a randomly selected character count.

The count is sampled from the half-open range and never splits a UTF-8 scalar. A count at or beyond the string’s character count returns the full input; an invalid or empty range panics.