(s: &str, maxrows: usize)
| 90 | } |
| 91 | |
| 92 | fn keep_only_maxrows(s: &str, maxrows: usize) -> String { |
| 93 | let lines: Vec<String> = s.lines().map(String::from).collect(); |
| 94 | |
| 95 | assert!(lines.len() >= maxrows + 4); // 4 lines for top and bottom border |
| 96 | |
| 97 | let last_line = &lines[lines.len() - 1]; // bottom border line |
| 98 | |
| 99 | let spaces = last_line.len().saturating_sub(4); |
| 100 | let dotted_line = format!("| .{}|", " ".repeat(spaces)); |
| 101 | |
| 102 | let mut result = lines[0..(maxrows + 3)].to_vec(); // Keep top border and `maxrows` lines |
| 103 | result.extend(vec![dotted_line; 3]); // Append ... lines |
| 104 | result.push(last_line.clone()); |
| 105 | |
| 106 | result.join("\n") |
| 107 | } |
| 108 | |
| 109 | fn format_batches_with_maxrows<W: std::io::Write>( |
| 110 | writer: &mut W, |
no test coverage detected
searching dependent graphs…