#zip #option #result #util #functional

no-std storage_zip

Utility functions library for zipping Options and Results into tuples

2 releases

0.1.1 Dec 22, 2019
0.1.0 Dec 22, 2019

#264 in No standard library

Download history 58/week @ 2021-05-04 162/week @ 2021-05-11 42/week @ 2021-05-18 38/week @ 2021-06-08 18/week @ 2021-06-15 1/week @ 2021-06-22 11/week @ 2021-06-29 28/week @ 2021-07-13 61/week @ 2021-07-20 131/week @ 2021-07-27 62/week @ 2021-08-03 33/week @ 2021-08-17

121 downloads per month


117 lines

Crates.io Documentation


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);


Licensed under either of

at your option.


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.

No runtime deps