#io #chain #chained #chainedreader

multi_reader

MultiReader - a composite reader implementation

1 unstable release

Uses old Rust 2015

0.1.0 Aug 24, 2016

#132 in #chain

Download history 323/week @ 2024-03-14 446/week @ 2024-03-21 569/week @ 2024-03-28 155/week @ 2024-04-04 87/week @ 2024-04-11 109/week @ 2024-04-18 195/week @ 2024-04-25 225/week @ 2024-05-02 416/week @ 2024-05-09 366/week @ 2024-05-16 158/week @ 2024-05-23 142/week @ 2024-05-30 1565/week @ 2024-06-06 2213/week @ 2024-06-13 2564/week @ 2024-06-20 3022/week @ 2024-06-27

9,393 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