Skip to main content

split_lines

Function split_lines 

Source
pub fn split_lines(text: &str) -> Vec<&str>
Expand description

Split text into lines, without a phantom trailing empty line.

An empty input has no lines, not one empty line. Treating it as one makes “created a file” render as “emptied an existing file”, which is a materially different (and wrong) story to a reviewer.

\r\n, a lone \r and \n all end a line. Lines are borrowed slices found by scanning bytes rather than built with replace and split: the terminators are ASCII, so every cut lands on a character boundary, and the substring search behind replace brought panic paths whose message formatting was a quarter of the WASM module.