Split on newlines - use lines



examples/strings/split-lines/src/main.rs
fn main() {
    let text = "row 1\nrow 2\nrow 3\n";
    println!("{text}");
    println!("-----");

    let lines = text.lines();
    for line in lines {
        println!("line: {line}");
    }
}

row 1
row 2
row 3

-----
line: row 1
line: row 2
line: row 3