is_short on its own doesn't really work with nesting, e.g. (5, 6) is short, so is (5, (6, 7)), but if you keep nesting two-tuples of integers you'll eventually hit something that is "not short". (Though maybe this could be tracked in the type system via specialization).
I was recently playing around with a similar usecase (formatting JSON like output for user display) and ended up going with a trait like:
trait LengthEstimate {
/// Can shortcircuit and return `max` if it is more than that
fn estimate(&self, max: usize) -> usize;
}
being able to shortcircuit to avoid recursing into deeply nested types or long arrays is also useful, e.g. for an array I do:
let mut len = 4;
for item in &self {
len += item.estimate(max - len) + 2;
if len >= max {
return len;
}
}
len