Renders a nested JSON value into a single table cell without dumping raw JSON. Arrays of objects become `name (file:line)`-style summaries; plain objects become compact `k=v` strings; arrays of scalars are comma-joined.
(v: &Value)
| 441 | /// JSON. Arrays of objects become `name (file:line)`-style summaries; plain |
| 442 | /// objects become compact `k=v` strings; arrays of scalars are comma-joined. |
| 443 | fn nested_cell_str(v: &Value) -> String { |
| 444 | const MAX_ITEMS: usize = 3; |
| 445 | |
| 446 | match v { |
| 447 | Value::Array(arr) => { |
| 448 | if arr.is_empty() { |
| 449 | return "none".to_string(); |
| 450 | } |
| 451 | let shown: Vec<String> = arr |
| 452 | .iter() |
| 453 | .take(MAX_ITEMS) |
| 454 | .map(|e| match e { |
| 455 | Value::Object(obj) => summarize_object(obj), |
| 456 | _ => scalar_str(e), |
| 457 | }) |
| 458 | .collect(); |
| 459 | if arr.len() > MAX_ITEMS { |
| 460 | format!( |
| 461 | "{} … (+{} more, {} total)", |
| 462 | shown.join("; "), |
| 463 | arr.len() - MAX_ITEMS, |
| 464 | arr.len() |
| 465 | ) |
| 466 | } else { |
| 467 | shown.join("; ") |
| 468 | } |
| 469 | } |
| 470 | Value::Object(obj) => summarize_object(obj), |
| 471 | _ => scalar_str(v), |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | /// Compact one-line summary of an object for a table cell. Prefers a |
| 476 | /// `name (file:line)` shape when those keys exist, else `k=v` pairs. |
no test coverage detected