#lines #reverse #reader #buffer #iterator

rev_lines

Rust Iterator for reading files line by line with a buffer in reverse

5 unstable releases

0.3.0 Jun 22, 2023
0.2.2 May 10, 2023
0.2.1 Apr 27, 2017
0.2.0 Feb 1, 2017
0.1.0 Feb 1, 2017

#409 in Algorithms

Download history 2037/week @ 2023-10-30 2298/week @ 2023-11-06 1442/week @ 2023-11-13 1339/week @ 2023-11-20 2088/week @ 2023-11-27 2374/week @ 2023-12-04 2003/week @ 2023-12-11 1365/week @ 2023-12-18 736/week @ 2023-12-25 1363/week @ 2024-01-01 1890/week @ 2024-01-08 2249/week @ 2024-01-15 1878/week @ 2024-01-22 2042/week @ 2024-01-29 1348/week @ 2024-02-05 1695/week @ 2024-02-12

6,996 downloads per month
Used in 6 crates

MIT license

17KB
264 lines

rev_lines

rev-lines MIT licensed crates.io

This library provides a small Rust Iterator for reading files line by line with a buffer in reverse

Documentation

Documentation is available on Docs.rs.

Example

use std::fs::File;

use rev_lines::RevLines;

let file = File::open("README.md").unwrap();
let rev_lines = RevLines::new(file);

for line in rev_lines {
    println!("{:?}", line);
}

lib.rs:

RevLines

This library provides a small Rust Iterator for reading files or any BufReader line by line with buffering in reverse.

Example

use std::fs::File;

use rev_lines::RevLines;

let file = File::open("README.md").unwrap();
let rev_lines = RevLines::new(file);

for line in rev_lines {
    println!("{:?}", line);
}

If a line with invalid UTF-8 is encountered, the iterator will return None next, and stop iterating.

This method uses logic borrowed from uutils/coreutils tail

Dependencies

~325–780KB
~18K SLoC