#io #chain #chained #chainedreader

multi_reader

MultiReader - a composite reader implementation

1 unstable release

Uses old Rust 2015

0.1.0 Aug 24, 2016

#131 in #chain

Download history 361/week @ 2023-11-28 103/week @ 2023-12-05 285/week @ 2023-12-12 344/week @ 2023-12-19 73/week @ 2023-12-26 202/week @ 2024-01-02 493/week @ 2024-01-09 292/week @ 2024-01-16 280/week @ 2024-01-23 262/week @ 2024-01-30 479/week @ 2024-02-06 371/week @ 2024-02-13 340/week @ 2024-02-20 401/week @ 2024-02-27 371/week @ 2024-03-05 395/week @ 2024-03-12

1,523 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