storage_zip

Crates.iostorage_zip
lib.rsstorage_zip
version0.1.1
sourcesrc
created_at2019-12-22 23:02:40.105271
updated_at2019-12-22 23:04:50.330078
descriptionUtility functions library for zipping Options and Results into tuples.
homepagehttps://github.com/Jonathas-Conceicao/storage-zip-rs
repositoryhttps://github.com/Jonathas-Conceicao/storage-zip-rs
max_upload_size
id191623
size21,114
Jonathas Conceição (Jonathas-Conceicao)

documentation

README

Crates.io Documentation

storage_zip

This crate offers utility functions for zipping Options and Results into tuples.

It is instead to be used when different actions yields Options or Results values but the program flow can only proceed if all of them are Some or Ok. When used with Result, it requires that all the Results being zipped have the same error type and it will evaluate to the first error or to the tuple with all the Ok values.

With the crate you can do:

use storage_zip::OptionZip;

let option_value_one = Some(0);
let option_value_two = Some(5);

let zipped_options = Option::zip(option_value_one, option_value_two);
assert_eq!(zipped_options, Some((0, 5)));

The crate also provides zip functions with more arguments:

use storage_zip::ResultZip;
use std::fs::File;
use std::io;

let f1 = File::open("file1");
let f2 = File::open("file2");
let f3 = File::open("file3");

let zipped_result: Result<(File, File, File), io::Error> = Result::zip3(f1, f2, f3);

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 10

cargo fmt