(cells: &[String], aligns: &[Align], widths: &[usize])
| 339 | } |
| 340 | |
| 341 | fn table_line(cells: &[String], aligns: &[Align], widths: &[usize]) -> String { |
| 342 | let mut line = String::from("│"); |
| 343 | for (index, width) in widths.iter().enumerate() { |
| 344 | let cell = cells.get(index).map(String::as_str).unwrap_or(""); |
| 345 | let align = if index == 0 && cell.starts_with("(assuming ") { |
| 346 | Align::Right |
| 347 | } else { |
| 348 | aligns.get(index).copied().unwrap_or(Align::Left) |
| 349 | }; |
| 350 | line.push(' '); |
| 351 | line.push_str(&pad_cell(cell, width.saturating_sub(2), align)); |
| 352 | line.push(' '); |
| 353 | line.push('│'); |
| 354 | } |
| 355 | line |
| 356 | } |
| 357 | |
| 358 | fn pad_cell(cell: &str, width: usize, align: Align) -> String { |
| 359 | let visible = visible_width(cell); |
no test coverage detected