zsplit

LGPL 3.0 License Workflow Status Crates.io crev reviews

Split text into multiple files by line.

This is the library and not the CLI application. It is called zsplit-cli.

Examples

Simple

```Rust use zsplit::prelude::*;

let data = "0\n1\n2\n3\n4\n5\n6\n7\n8\n9"; let mut source = std::io::BufReader::new(data.asbytes()); let mut destinations = vec![ Destination::buffer(), // firstdestination Destination::buffer(), // seconddestination Destination::buffer(), // thirddestination ];

splitroundrobin(&mut source, &mut destinations).unwrap();

let thirddestination = destinations.pop().unwrap(); let seconddestination = destinations.pop().unwrap(); let first_destination = destinations.pop().unwrap();

asserteq!(firstdestination.intoutf8string().unwrap(), "0\n3\n6\n9"); asserteq!(seconddestination.intoutf8string().unwrap(), "1\n4\n7\n"); asserteq!(thirddestination.intoutf8string().unwrap(), "2\n5\n8\n"); ```

Visualisation of simple

Unsymmetric Distribution

```Rust use zsplit::prelude::*;

let data = "0\n1\n2\n3\n4\n5\n6\n7\n8\n9"; let mut source = std::io::BufReader::new(data.asbytes()); let mut destinations = vec![ Destination::bufferwithlines(3), // firstdestination Destination::bufferwithlines(3), // seconddestination Destination::buffer(), // thirddestination ];

splitroundrobin(&mut source, &mut destinations).unwrap();

let thirddestination = destinations.pop().unwrap(); let seconddestination = destinations.pop().unwrap(); let first_destination = destinations.pop().unwrap();

asserteq!(firstdestination.intoutf8string().unwrap(), "0\n1\n2\n7\n8\n9\n"); asserteq!(seconddestination.intoutf8string().unwrap(), "3\n4\n5\n"); asserteq!(thirddestination.intoutf8string().unwrap(), "6\n"); ```

Visualisation of unsymmetric distribution

CREV - Rust code reviews - Raise awareness

Please, spread this info !\ Open source code needs a community effort to express trustworthiness.\ Start with reading the reviews of the crates you use. Example: web.crev.dev/rust-reviews/crate/num-traits/ \ Than install the CLI cargo-crev. Read the Getting Started guide. \ On your Rust project, verify the trustworthiness of all dependencies, including transient dependencies with cargo crev verify\ Write a new review ! \ Describe the crates you trust. Or warn about the crate versions you think are dangerous.\ Help other developers, inform them and share your opinion.\ Use the helper on this webpage: web.crev.dev/rust-reviews/review_new