Skip to main content

insert_line

Function insert_line 

Source
pub fn insert_line(lines: &[&str], line_number: usize, new_line: &str) -> String
Expand description

Insert new_line before the 1-based line_number in lines, returning the complete new file content as a String.

Inserting at line_number == lines.len() + 1 appends after the last line.

The returned string always ends with a newline.