Skip to main content

parse_diff_line

Function parse_diff_line 

Source
pub fn parse_diff_line(line: &str) -> DiffLineKind
Expand description

Parse a single line from generate_diff output. The format is format!("{:>4}{marker}{content}", line_num, marker, content) where marker is one of " " (context), " - " (removed), " + " (added) — all 3 bytes wide. Lives next to the markers above so the producer and the parser cannot drift independently.

Lines that don’t follow the expected shape (no leading digit, no marker after the digits, etc.) fall through to Context. That keeps the renderer’s match exhaustive without panicking on malformed input.