#file-line #line #reverse #iterator #file-reader #buffer #reader

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

#504 in Algorithms

Download history 2661/week @ 2024-08-16 3841/week @ 2024-08-23 2449/week @ 2024-08-30 2846/week @ 2024-09-06 2654/week @ 2024-09-13 1820/week @ 2024-09-20 2076/week @ 2024-09-27 1519/week @ 2024-10-04 2160/week @ 2024-10-11 2252/week @ 2024-10-18 1218/week @ 2024-10-25 1582/week @ 2024-11-01 2263/week @ 2024-11-08 3360/week @ 2024-11-15 1750/week @ 2024-11-22 1418/week @ 2024-11-29

9,058 downloads per month
Used in 12 crates (11 directly)

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

~245–710KB
~17K SLoC