bounded_detail: use std char-boundary floor/ceil instead of hand loops

The hand loops hung under mutation (infinite loops); std does it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-19 19:07:23 +02:00
commit ec45906ead

View file

@ -9750,14 +9750,10 @@ fn bounded_detail(value: &str) -> String {
if value.len() <= DETAIL_LIMIT {
return value;
}
let mut head = DETAIL_HEAD;
while !value.is_char_boundary(head) {
head -= 1;
}
let mut tail = value.len() - (DETAIL_LIMIT - DETAIL_HEAD - DETAIL_ELISION.len());
while !value.is_char_boundary(tail) {
tail += 1;
}
let head = value.floor_char_boundary(DETAIL_HEAD);
let tail = value.ceil_char_boundary(
value.len() - (DETAIL_LIMIT - DETAIL_HEAD - DETAIL_ELISION.len()),
);
format!("{}{DETAIL_ELISION}{}", &value[..head], &value[tail..])
}