Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonathas-conceicao/storage-zip-rs
Utility functions library for zipping Options and Results into tuples.
https://github.com/jonathas-conceicao/storage-zip-rs
Last synced: about 1 month ago
JSON representation
Utility functions library for zipping Options and Results into tuples.
- Host: GitHub
- URL: https://github.com/jonathas-conceicao/storage-zip-rs
- Owner: Jonathas-Conceicao
- License: apache-2.0
- Created: 2019-12-21T06:56:31.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-23T23:36:37.000Z (about 5 years ago)
- Last Synced: 2024-11-29T13:48:24.132Z (about 2 months ago)
- Language: Rust
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
[![Crates.io](https://img.shields.io/crates/v/storage-zip.svg)](https://crates.io/crates/storage-zip)
[![Documentation](https://docs.rs/storage_zip/badge.svg)](https://docs.rs/storage_zip)# storage_zip
This crate offers utility functions for zipping `Option` and `Result`
values into tuples.This is intended to be used when different actions yields multiple
`Option` or `Result` values but the program flow can only proceed if
all of them are `Some` or `Ok`.When it is used with a `Result` based value, it requires that all the
`Result` values 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:
```rust
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:
```rust
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
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)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.