Skip to main content

apply_hunks

Function apply_hunks 

Source
pub fn apply_hunks(base: Option<&[u8]>, hunks: &[&Hunk]) -> Vec<u8> ⓘ
Expand description

Apply a subset of one file’s hunks to its base content. Hunks are disjoint under -U0.

An absent file’s base is ONE EMPTY LINE, not zero lines: b"".split(b'\n') yields [b""], and that trailing empty element is what encodes “ends with a newline”. Dropping it loses the final byte of every created file.