#io #chain #chained #chainedreader

multi_reader

MultiReader - a composite reader implementation

1 unstable release

Uses old Rust 2015

0.1.0 Aug 24, 2016

#6 in #chained

Download history 184/week @ 2024-11-17 406/week @ 2024-11-24 458/week @ 2024-12-01 268/week @ 2024-12-08 996/week @ 2024-12-15 175/week @ 2024-12-22 222/week @ 2024-12-29 2668/week @ 2025-01-05 24808/week @ 2025-01-12 2573/week @ 2025-01-19 2045/week @ 2025-01-26 1722/week @ 2025-02-02 1787/week @ 2025-02-09 1582/week @ 2025-02-16 2170/week @ 2025-02-23 2825/week @ 2025-03-02

8,602 downloads per month
Used in 3 crates

Custom license

6KB
115 lines

MultiReader - a composite reader implementation.

Build Status

Like std::io::Chain but allows to chain more than two readers together.

Usage

extern crate multi_reader;
use std::env;
use std::io::{BufRead, BufReader};
use std::fs::File;

fn main() {
    let args: Vec<_> = env::args().collect();
    let files = args[1..].iter().map(|f| File::open(f).expect("File not found"));
    let reader = BufReader::new(multi_reader::MultiReader::new(files));
    println!("Total lines count: {}", reader.lines().count());
}

Examples

Run cargo run --example main chained /path/to/file/a /path/to/file/b ....

Tests

cargo test

lib.rs:

A composite reader implementation.

Like io::Chain but allows to chain more than two readers together.

Use

extern crate multi_reader;
use std::env;
use std::io::{BufRead, BufReader};
use std::fs::File;

fn main() {
    let args: Vec<_> = env::args().collect();
    let files = args[1..].iter().map(|f| File::open(f).expect("File not found"));
    let reader = BufReader::new(multi_reader::MultiReader::new(files));
    println!("Total lines count: {}", reader.lines().count());
}

No runtime deps