Function mz_persist_types::stats::truncate_string

source ·
pub fn truncate_string(
    x: &str,
    max_len: usize,
    bound: TruncateBound
) -> Option<String>
Expand description

Truncates a string to the given maximum byte length.

The returned value is a valid utf-8 string. If bound is Lower, it will sort <= the original string, and if bound is Upper, it will sort >= the original string.

Lower bounds will always return Some. Upper bounds might return None if the part that fits in max_len is entirely made of char::MAX (so in practice, probably ~never).