#read-line #read #read-file #file

read_lines_with_blank

File to Vec<String> by line without losing or ending on blank lines

2 releases

Uses new Rust 2024

new 0.1.1 Apr 19, 2025
0.1.0 Apr 19, 2025

#607 in Filesystem

49 downloads per month
Used in ini-rs

MIT license

4KB

read_lines_with_blank

Read lines from a file or string while keeping blank lines and not ending on blank lines.

Usage

use read_lines_with_blank::*;

let f = File::open("foo.txt")?;
let mut reader = BufReader::new(f);

let lines_file = match read_lines_with_blank(&mut reader) {
    Ok(x) => x,
    Err(e) => return Err(e),
};

let str: &str = "line1\n\n\nline2\n";
let lines_str = match read_lines_with_blank_from_str(str) {
    Ok(x) => x,
    Err(e) => return Err(e),
};

No runtime deps