pub fn head_tail_truncate(
value: &str,
max_chars: usize,
marker: &str,
) -> (String, bool)Expand description
Truncate value to max_chars chars by keeping a head and a tail joined by
marker, preserving context from both ends of the text.
Returns (text, was_truncated). When the budget is too small to fit the
marker plus meaningful context, falls back to a head-only prefix with a
[truncated] suffix, respecting the max_chars budget.
let (out, truncated) = head_tail_truncate("short", 64, " ... ");
assert_eq!(out, "short");
assert!(!truncated);