Skip to main content

split_keeping_newlines

Function split_keeping_newlines 

Source
pub fn split_keeping_newlines(text: &[u8]) -> Vec<Vec<u8>>
Expand description

What: Split bytes into lines, each keeping its newline; an unterminated last line stays as it is. Why: Hunk bodies and blob contents are compared line by line, newline included, the way Git’s xdiff compares them.

In TS you’d write (pseudocode):

splitKeepingNewlines('a\nb'); // ['a\n', 'b']