This week I’ve published a Rust library of helper functions and structures for iterating over text and files. Check the documentation for detailed getting started and usage instructions, the source code is available on GitHub. What follows is the TLDR for installation and usage…

Cargo.toml (snip)

[dependencies]
iterate-text = "0.0.1"

src/main.rs (example)

#!/usr/bin/env rust


use iterate_text::file::lines::IterateFileLines;


fn main() {
    let mut iter = IterateFileLines::new("tests/file/lines/file.txt");

    assert_eq!(iter.next(), Some("First line\n"));
    assert_eq!(iter.next(), Some("Second line\n"));
    assert_eq!(iter.next(), Some("Third line\n"));
    assert_eq!(iter.next(), None);
}


Application examples may be run by cloning the repository from GitHub

Clone

mkdir -vp ~/git/hub/rust-utilities

cd ~/git/hub/rust-utilities

git clone git@github.com:rust-utilities/iterate-text.git

examples/version-compare.rs

cargo run --example file-reader -- --file .github/README.md -c 10