Crate reverse_lines
source ·Expand description
ReverseLines
This library provides a small Rust Iterator for reading files or anything that implements
std::io::Seek
and std::io::Read
in reverse.
It is a rework of rev_lines with improved error handling and allowance for more types.
Example
extern crate reverse_lines;
use reverse_lines::ReverseLines;
use std::io::BufReader;
use std::fs::File;
fn main() {
let file = File::open("tests/multi_line_file").unwrap();
let reverse_lines = ReverseLines::new(BufReader::new(file)).unwrap();
for line in reverse_lines {
println!("{}", line.unwrap());
}
}
If a line with invalid UTF-8 is encountered, or if there is an I/O error, the iterator will
yield an std::io::Error
.
This method uses logic borrowed from uutils/coreutils tail and code borrowed from rev_lines.
Structs
ReverseLines
struct