pub fn render_file_block(file: &FileDiff, color: bool) -> RenderedFileExpand description
Renders a single file diff into formatted output lines.
Transforms file diff data into visual representation with colors, separators, and grouped imports. Pre-calculates visual width for grid layout optimization.
§Structure
File: path/to/file.rs <- Header (cyan + bold)
──────────────────────────── <- Separator
Imports (file top) <- Import section header
+ use std::fs::write; <- Grouped imports (green)
analyzer_name (N issues) <- Analyzer section (green + bold)
Line 42 <- Line number (cyan)
- old code <- Removal (red)
+ new code <- Addition (green)
════════════════════════════ <- End separator§Arguments
file- File diff containing all changes
§Returns
RenderedFile with formatted lines and calculated width
§Performance
- Pre-allocates Vec with estimated capacity
- Groups and deduplicates imports once
- Calculates width incrementally (single pass)
- Minimizes string allocations
§Examples
use cargo_quality::differ::{display::render::render_file_block, types::FileDiff};
let file_diff = FileDiff::new("test.rs".to_string());
let rendered = render_file_block(&file_diff, false);
assert!(!rendered.lines.is_empty());
assert!(rendered.width >= 40);